简体   繁体   English

Firebase待处理动态链接无效

[英]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. 根据Firebase动态链接文档,即使未安装应用程序,如果用户打开设备上的链接,Appstore上的应用程序页面也会打开,一旦安装了应用程序,应用程序就会在第一次启动时处理该链接。 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: 经过一些调查后,我发现Firebase有一些名为“待定动态链接”的东西,并且可以预期,使用这些链接调用AppDelegate方法:

- (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 这个假设的来源: 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 但是当我尝试测试这个“待定动态lynks”功能时,这两个AppDelegate方法都没有被调用

-(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). 同时,如果安装了应用程序,动态链接将按预期工作,通过openURL:方法打开(如果通过Chrome从gmail应用程序打开),通过iOS9及以后的通用链接打开(如果从Notes或Mail应用程序打开)(通过Safari实际上)。

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. 问题是,默认情况下,Firebase尝试使用URL方案打开应用程序,该方案等于应用程序包ID,这不是我的情况。 I have changed my configuration of Firebase to the next: 我已将Firebase的配置更改为下一个:

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, eg openURL: method is called now on the very first app open if link was opened on the device before. 并且它开始工作,例如openURL:如果之前在设备上打开链接,则在第一个应用程序打开时立即调用方法。

The post-install deeplinking is based on checking a flag: 安装后深度链接基于检查标志:

  • [FIRApp configure] called [FIRApp configure]调用
  • Dynamic Links SDK checks whether it is a fresh install (eg no flag present) 动态链接SDK检查它是否是全新安装(例如,没有标记存在)
  • If so, it calls the Dynamic Links API to check if there is a dynamic link to resolve 如果是这样,它会调用Dynamic Links API来检查是否有要解析的动态链接
  • If yes, the SDK calls [[UIApplication sharedApplication] openURL:url]; 如果是,则SDK调用[[UIApplication sharedApplication] openURL:url]; using the custom URL scheme set up manually on FIROptions or the lowercase bundle ID (eg com.foo.bar). 使用在FIROptions上手动设置的自定义URL方案或小写包ID(例如com.foo.bar)。

If you're not receiving, check the custom URL scheme is properly defined. 如果您没有收到,请检查是否正确定义了自定义URL方案。

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. 为了澄清,如果我对链接的Google网上论坛帖子的理解是正确的,Firebase动态链接库只会检查一次“待处理动态链接”。 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. openURL方法响应自定义URI方案, continueUserActivity方法响应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. Firebase文档确实说openURL方法总是在初始安装时调用,但我从未见过其他任何地方发生的事情,因此他们可能会做一些不寻常的事情。

At risk of going off-topic, I'd suggest taking a look at Branch.io (full disclosure: I'm on the team). 有可能偏离主题,我建议看看Branch.io (完全披露:我在团队中)。 You'll get all of the benefits of Dynamic Links, plus a laundry list of extra functionality and clearer documentation :) 您将获得动态链接的所有好处,以及额外功能和更清晰文档的清单:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM