在iOS上实现Firebase动态链接时,当您单击打开动态链接时,调试控制台中会出现错误消息:
未找到application:continueUserActivity:restorationHandler:的FIRAnalytics/警告实现。请将处理程序添加到应用程序代表中。班级: LLAppDelegateProxy
我创建了一个最小化的项目来重现这个问题。新项目只包含
Pod 'Localytics'
Pod 'Firebase/DynamicLinks’和唯一添加到AppDelegate.swift的代码
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
Localytics.autoIntegrate("apikey", launchOptions: launchOptions)
return true
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
let dynamicLink = FIRDynamicLinks.dynamicLinks()?.dynamicLink(fromCustomSchemeURL: url)
if let dynamicLink = dynamicLink {
print(dynamicLink.url)
return true
}
return false
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
guard let dynamicLinks = FIRDynamicLinks.dynamicLinks() else {
return false
}
let handled = dynamicLinks.handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
print(dynamiclink?.url)
}
return handled
}看起来,Firebase试图在Localytics的LLAppDelegateProxy中调用LLAppDelegateProxy而不是AppDelegate.swift。还有一篇来自GitHub的Branch.io:https://github.com/BranchMetrics/ios-branch-deep-linking/issues/485的文章
这篇文章指出,Google和Localytics之间存在冲突,导致分支无法在正确的位置找到函数application:continueUserActivity:restorationHandler:。
我遵循他们的第三项建议,改变方法swizzling:
//Their solution in Objc
SwizzleInstanceSelectorWithNewSelector(
[[UIApplication sharedApplication].delegate class],
@selector(application:continueUserActivity:restorationHandler:),
[self class],
@selector(BRapplication:continueUserActivity:restorationHandler:)
);
//My swift version in AppDelegate.swift
let originalSelector = #selector(AppDelegate.application(_:continueUserActivity:restorationHandler:))
let swizzledSelector = #selector(AppDelegate.firApplication(_:continueUserActivity:restorationHandler:))
let originalMethod = class_getClassMethod(AppDelegate.self, originalSelector)
let swizzledMethod = class_getClassMethod(AppDelegate.self, swizzledSelector)
method_exchangeImplementations(originalMethod, swizzledMethod)但是,这对我不起作用。我仍然看到警告和链接仍然没有处理。
你能帮我修一下swizzling方法吗?或者你有一个更好的解决方案:]
发布于 2017-03-13 16:23:40
很抱歉对这个问题的答复太迟了。
我们联系了当地和火场。Localytics为我们提供了一个解决方案,需要从自动集成转向手动集成。虽然使用手动集成有点烦人,但它解决了以下问题:]
发布于 2018-09-12 12:45:18
在花了差不多一整天之后,我已经解决了这个问题。
下面的解决方案就像魅力一样有效!
通过将FirebaseAppDelegateProxyEnabled设置为应用程序的info.plist中的NO,可以防止Firebase对AppDelegate中的方法进行切换
https://docs.localytics.com/dev/ios.html#integrating-with-firebase
干杯
https://stackoverflow.com/questions/41170244
复制相似问题