打开iOS应用“continue userActivity"后:未调用方法 - Firebase 动态链接 [英] After opening iOS app "continue userActivity:" method isn't called - Firebase dynamic link

查看:94
本文介绍了打开iOS应用“continue userActivity"后:未调用方法 - Firebase 动态链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功集成 Firebase 动态链接,当我点击动态链接时,我的应用正在打开.

I have successfully integrated Firebase dynamic links and when I click on dynamic link then my app is opening.

我面临的问题是从动态链接打开应用程序后,应该调用continue userActivity: 方法,但没有任何反应.

The issues I'm facing is after opening app from dynamic links, continue userActivity: method should be called, but nothing happens.

我已经检查了所有可能的事情,但没有发现问题.

I've checked the all the possible thing but didn't recognised the issue.

我已经为此搜索了 SO,但没有一个答案对我有帮助.

I've searched the SO for this but none of the answer helped me.

我的代码:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

  GIDSignIn.sharedInstance().clientID = kGoogleSignInClientId
  FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

 // DynamicLinks.performDiagnostics(completion: nil)

  FirebaseApp.configure()

  return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

  if url.absoluteString.contains(kFBAppId) {

    return FBSDKApplicationDelegate.sharedInstance().application(app, open: url, options: options)

  }

  if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url) {
    print(dynamicLink.url ?? URL(string: "test") as Any)
    return true
  }

    return GIDSignIn.sharedInstance().handle(url, sourceApplication: options[.sourceApplication] as? String, annotation: options[.annotation])

}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {

  //This method is not getting called
}

推荐答案

我不知道他们是否保留了他们的文档.是否是最新的.

I don't know whether they keep their doc. up to date or not.

我刚刚从 Google 的官方 Firebase 动态链接文档中复制粘贴了代码.

I have just copy-pasted the code from the Google's official Firebase dynamic link document.

为什么没有调用 continue userActivity: 方法?

Why was the continue userActivity: method is not called?

原因是(见下面方法的区别)

The reason is (See the difference in following method)

从谷歌文档复制粘贴.- 错误的

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restoreHandler: @escaping ([UIUserActivityRestoring]?) -> Void) ->布尔{

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {

}

我写了这个(没有从谷歌文档复制粘贴.) - 更正一个

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restoreHandler: @escaping ([Any]?) -> Void) ->布尔{

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {

}

我已经把不同之处加粗了.

这就是我尝试了好几个小时的方法.盲目相信google doc,真的很郁闷:-|

This is what I was trying for many hours. It is really very frustrating for me to blindly trust on google doc.:-|

希望这可以帮助其他人.

Hope this may help other.

这篇关于打开iOS应用“continue userActivity"后:未调用方法 - Firebase 动态链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆