After opening iOS app “continue userActivity:” method isn't called - Firebase dynamic link

后端 未结 4 933
独厮守ぢ
独厮守ぢ 2021-01-16 10:18

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

The issues I\'m facing is after opening app from dynam

相关标签:
4条回答
  • 2021-01-16 10:46

    You need to check two times.

    1. When app. is running in the background and is opening from Link: Delegate method is:func checkForTransferedTicket(_ userActivity: NSUserActivity) { }

    2. When app. is NOT running in background and is opening from Link:

      func scene(_ scene: UIScene, willConnectTo session: UISceneSession,options connectionOptions: UIScene.ConnectionOptions) { if let userActivity = connectionOptions.userActivities.first {
                       print(userActivity)
                   }
           }
      
    0 讨论(0)
  • 2021-01-16 10:58

    The blunder of Google.

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

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

    Why was the continue userActivity: method is not called?

    The reason is (See the difference in following method)

    Copy pasted from google doc. - Wrong one

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

    }

    I wrote this (without copy paste from google doc.) - Correct one

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

    }

    I've made bold the difference.

    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.

    0 讨论(0)
  • 2021-01-16 11:05

    Additional answer for those using separate SceneDelegate.swift apart from AppDelegate.swift: This method in AppDelegate >

    func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
        if userActivity.activityType == CSSearchableItemActionType {
    
    }
    

    is now in SceneDelegate >

    func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
    
    }
    
    0 讨论(0)
  • 2021-01-16 11:05

    To handle universal link in your application first you have to add an entitlement file with supported urls in your application.

    To do so open Xcode, Select your project, Goto Capabilities and find Associated Domain section.

    Turn on this capability and add an entry for each domain your app supports with a prefix of applinks:

    Now you have to implement application(_:continue:restorationHandler:) in your AppDelegate file. This method will be called when user click on link which your supports.

    0 讨论(0)
提交回复
热议问题