[英]AppDelegate ContinueUserActivity not called when launching app from deep link, Firebase SDK is to blame
In my AppDelegate class I'm trying to handle deep links that launch my Xamarin iOS app, so that I can navigate the user to the proper place in the app based on the url.在我的 AppDelegate 类中,我试图处理启动我的 Xamarin iOS 应用程序的深层链接,以便我可以根据 url 将用户导航到应用程序中的正确位置。 I'm overriding all of the ContinueUserActivity and OpenUrl methods, however none of these methods are ever called (either when the app is closed or just suspended.) I'm testing by including the deep link ( https://example.com/path1/path2 ) in a iOS Calendar event, then tapping on the link on my iPhone 6 (running iOS 12.3.1) while the app is running in debug mode.
我覆盖了所有 ContinueUserActivity 和 OpenUrl 方法,但是这些方法都没有被调用(当应用程序关闭或刚刚暂停时。)我正在通过包含深层链接( https://example.com/ path1/path2 ),然后在应用程序在调试模式下运行时点击我的 iPhone 6(运行 iOS 12.3.1)上的链接。 My app does open when the link is tapped, but none of the break points are hit in any of the overridden methods.
我的应用程序在点击链接时会打开,但在任何重写的方法中都没有命中任何断点。
public override bool ContinueUserActivity (UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler) {
return true;
}
public override bool OpenUrl (UIKit.UIApplication app, Foundation.NSUrl url, Foundation.NSDictionary options) {
return true;
}
public new bool OpenUrl (UIKit.UIApplication app, Foundation.NSUrl url, UIKit.UIApplicationOpenUrlOptions options) {
return true;
}
public override bool OpenUrl (UIApplication application, NSUrl url, string sourceApplication, NSObject annotation) {
return true;
}
I think that the universal links are set up correctly (associated domains, etc...), otherwise it wouldn't be launching my app.我认为通用链接设置正确(关联域等),否则它不会启动我的应用程序。 Also, I've confirmed that my FinishedLaunching method returns true, as I read elsewhere that if this returns false then ContinueUserActivity and OpenUrl aren't called.
此外,我已经确认我的 FinishedLaunching 方法返回 true,正如我在别处读到的那样,如果返回 false,则不会调用 ContinueUserActivity 和 OpenUrl。 Other overridden methods in AppDelegate like OnActivated and WillContinueUserActivity are called, but not the ones that I need to get at the deep link url.
AppDelegate 中的其他覆盖方法(如 OnActivated 和 WillContinueUserActivity )被调用,但不是我需要在深层链接 url 处获取的方法。
Is this a Xamarin iOS bug?这是 Xamarin iOS 错误吗? Or is there something I'm doing incorrectly?
还是我做错了什么? I'm using the latest version of Xamarin iOS (12.8.0.2).
我使用的是最新版本的 Xamarin iOS (12.8.0.2)。
EDIT: A little more info... It turns out that the Firebase SDK is to blame for breaking deep links.编辑:更多信息......事实证明,Firebase SDK 是破坏深层链接的罪魁祸首。 If I disable it, then clicking on a deep link will successfully call ContinueUserActivity.
如果我禁用它,那么单击深层链接将成功调用 ContinueUserActivity。 However, as soon as I call Firebase.Core.App.Configure(), then subsequent deep link clicks will still open the app but no longer call ContinueUserActivity.
但是,一旦我调用 Firebase.Core.App.Configure(),随后的深层链接点击仍将打开应用程序,但不再调用 ContinueUserActivity。 I'm not sure how to work around this issue, as I need Firebase for Analytics (Google Analytics is going away soon...)
我不知道如何解决这个问题,因为我需要 Firebase for Analytics(Google Analytics 即将消失......)
The credit goes to @Andrew McKinley, but for others who run into the same issue the resolution is to add a new key to your Info.plist file:归功于@Andrew McKinley,但对于遇到相同问题的其他人,解决方案是向您的 Info.plist 文件添加一个新密钥:
Key: FirebaseAppDelegateProxyEnabled Type: Boolean Value: No (false)键:FirebaseAppDelegateProxyEnabled 类型:布尔值:否 (false)
After that Firebase stops hijacking handling of deep link urls, so AppDelegate.ContinueUserActivity is correctly called when a deep link is clicked.之后 Firebase 停止劫持处理深层链接 url,因此在单击深层链接时会正确调用 AppDelegate.ContinueUserActivity。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.