9
votes

According to the Firebase Dynamic Links documentation, even if app is not installed, if user opens the link on the device, app page on Appstore opened, and once app installed, application handles the link on the first launch. After some investigation how this handles, I found that Firebase has something called "pending dynamic links", and it is expected, that AppDelegate method is called with these links:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options

The source of this assumption: https://groups.google.com/forum/#!msg/firebase-talk/2STD8eIi61I/8KJqZN7TBAAJ

But when I try to test this "pending dynamic lynks" feature, neither of these two AppDelegate methods been called

-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options

At the same time, if app installed, dynamic links work as expected, opening through the openURL: method if opened from gmail app through Chrome, through Universal links on iOS9 and later if opened from Notes or Mail app (through Safari actually).

So, my question is: How the "pending dynamic links" are expecting to work? What could be the reason my app doesn't handle them?

----------------EDIT----------------

The problem was, that by default Firebase tries to open the app with URL scheme which equals to the app bundle ID, which was not my case. I have changed my configuration of Firebase to the next:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
options.deepLinkURLScheme = @"MY-CUSTOM-SCHEME";
[FIRApp configureWithOptions:options];

And it start working, e.g. openURL: method is called now on the very first app open if link was opened on the device before.

2

2 Answers

8
votes

The post-install deeplinking is based on checking a flag:

  • [FIRApp configure] called
  • Dynamic Links SDK checks whether it is a fresh install (e.g. no flag present)
  • If so, it calls the Dynamic Links API to check if there is a dynamic link to resolve
  • If yes, the SDK calls [[UIApplication sharedApplication] openURL:url]; using the custom URL scheme set up manually on FIROptions or the lowercase bundle ID (e.g. com.foo.bar).

If you're not receiving, check the custom URL scheme is properly defined.

0
votes

To clarify, if my understanding of the linked Google Groups post is correct, the Firebase Dynamic Links library only checks for 'pending dynamic links' once. Ever. So if the app has already checked for pending links, you'd need to delete it and reinstall to check again.

Now to answer your question, neither of those two methods would usually be called if the app isn't installed when the link is clicked. The openURL method responds to custom URI schemes, and the continueUserActivity method responds to Universal Links. Neither of those is being used when the app is manually opened by the user after downloading for the first time. The Firebase documentation does say the openURL method always called on initial install, but I have never seen happening anywhere else so it's possible they are doing something unusual.

At risk of going off-topic, I'd suggest taking a look at Branch.io (full disclosure: I'm on the team). You'll get all of the benefits of Dynamic Links, plus a laundry list of extra functionality and clearer documentation :)