Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[firebase_dynamic_links] Don't crash if activity is missing #1989

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public boolean onNewIntent(Intent intent) {
FirebaseDynamicLinks.getInstance()
.getDynamicLink(intent)
.addOnSuccessListener(
registrar.activity(),
new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
Expand All @@ -53,7 +52,6 @@ public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
}
})
.addOnFailureListener(
registrar.activity(),
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Expand Down Expand Up @@ -117,6 +115,11 @@ private Map<String, Object> getMapFromPendingDynamicLinkData(
}

private void handleGetInitialDynamicLink(final Result result) {
if (registrar.activity() == null) {
result.success(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use result.error() here. Wouldn't the user want to know that it failed because there was no activity?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the activity has not started, then there is no initial link. I think it is WAI that it returns null.

return;
}

FirebaseDynamicLinks.getInstance()
.getDynamicLink(registrar.activity().getIntent())
.addOnSuccessListener(
Expand Down