gpt4 book ai didi

swift - Localytics 实现时,Firebase 动态链接找不到 continueUserActivity

转载 作者:行者123 更新时间:2023-11-28 08:21:34 25 4
gpt4 key购买 nike

在 iOS 上实现 Firebase 动态链接时,当您点击打开动态链接时,调试控制台中出现错误消息:

FIRAnalytics/WARNING Implementation of application:continueUserActivity:restorationHandler: not found. Please add the handler into your App Delegate. Class: 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 中调用 application:continueUserActivity:restorationHandler: 而不是 AppDelegate.swift。还有一个来自 Branch.io 的 GitHub 问题帖子:https://github.com/BranchMetrics/ios-branch-deep-linking/issues/485

帖子指出 Google Analytics 和 Localytics 之间存在冲突,导致 Branch 无法在正确的位置找到函数 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 的问题吗,或者你有更好的解决方案:]

最佳答案

抱歉,关于这个问题的回答晚了。

我们联系了 Localytics 和 Firebase。 Localytics 为我们提供了一个解决方案,需要从自动集成切换到手动集成。虽然使用手动集成有点烦人,但它解决了这个问题:]

关于swift - Localytics 实现时,Firebase 动态链接找不到 continueUserActivity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41170244/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com