-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dynamic_links]: fix initialization process #2817
[dynamic_links]: fix initialization process #2817
Conversation
} | ||
|
||
- (BOOL)checkForDynamicLink:(NSURL *)url { | ||
FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url]; | ||
if (dynamicLink) { | ||
if (dynamicLink.url) _initialLink = dynamicLink; | ||
[self onDeepLinkResult: dynamicLink error: nil]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info: when the checkForDynamicLink
method is executed, the getInitialLink()
method had been already called. In such a case the app won't read _initialLink
.
After the change, the link is delivered to onLink(onSuccess: xyz)
callback
return [self onInitialLink:userActivity]; | ||
continueUserActivity:(NSUserActivity *)userActivity | ||
restorationHandler:(void (^)(NSArray *))restorationHandler { | ||
BOOL handled = [[FIRDynamicLinks dynamicLinks] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info: previously _initiated
were beeing checked before calling async function [[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity
. So previously if getInitialLink
is called after the method is called but before it returns data. The link is lost.
After the change, the _initiated
is checked after the callback returns.
- (BOOL)application:(UIApplication *)application | ||
openURL:(NSURL *)url | ||
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options { | ||
return [self checkForDynamicLink:url]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info: nothing has changed, the method is moved lower where the rest of -application: xxx
method are placed.
Description: Fixing race-condition with getInitialLink and actuall setup this initial link on iOS devices Closes: firebase#100 Closes: firebase#1847 Closes: firebase#1861
702f71c
to
c0f5fe5
Compare
This PR is ready for review by I can't change it from draft. |
Hi @bparrishMines! Great that you taking care of this PR. Is it something that I can do for you related to this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for this PR.
@jacek-marchwicki could you please bump the version number and update the changelog? |
Summary: - Bump version number - Added description to changelog
@kroikie sorry it took me a while, but finally I did it! |
awesome fix! I spent 2 days trying to figure out why my links were acting weird. |
Description:
This is my first contribution to this project so I'm sorry if I made this in improper way.
Description
Fix race conditions related to the dynamic links initialization process.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
might be called by OS afterFirebaseDynamicLinks.instance.getInitialLink()
is called. In such a case the app won't retrieve the deep-link.FirebaseDynamicLinks.instance.getInitialLink()
is called while processing[FIRDynamicLinks dynamicLinks] openURL:(NSURL *)url handleUniversalLink
, the url is lost.FirebaseDynamicLinks.instance.getInitialLink()
call should be called afterFirebaseDynamicLinks.instance.onLink()
so url's aren't lost between those two calls.More info in the comments in the PR:
Related Issues
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?