Olexandr  Stepanov Olexandr Stepanov - 11 months ago 226
iOS Question

Firebase pending dynamic links not working

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:

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?


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.
method is called now on the very first app open if link was opened on the device before.

Answer Source

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.