URL Opening Swift App - Open Works - Called Function Does NOT work

后端 未结 2 1280
北恋
北恋 2020-12-19 06:43

Hello All – I am a newbie here ... trying to get my first iOS Swift (Xcode 11.2.1 / Swift 5 / iOS 13.2) app to open via URL and process the URL string. The app opens just f

相关标签:
2条回答
  • 2020-12-19 07:17

    you need to use this function in your appDelegate

    func application(_ application: UIApplication, continue userActivity: NSUserActivity,
                         restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
            if let incomingURL = userActivity.webpageURL {
               print(incomingURL)
            }
            return false
    
    }
    
    0 讨论(0)
  • 2020-12-19 07:27

    I just found a solution here: application(...continue userActivity...) method not called in ios 13

    The trick is to also implement the SceneDelegate.swift functions for Apps with iOS > 13. This function should be called if you open the URL confirmevent://HelloWorld:

    func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        print(URLContexts.debugDescription)
    }
    
    0 讨论(0)
提交回复
热议问题