Method 'scene(_:openURLContexts:)' is not called

后端 未结 3 1116
深忆病人
深忆病人 2021-01-17 10:44

In info.plist file I configured URL Identifier and URL Scheme successfully. Also I am able to open app using custom URL. The problem is when app la

相关标签:
3条回答
  • 2021-01-17 11:14

    Maybe this will help your situation.

    
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    
        let urlinfo = connectionOptions.urlContexts
        let url = urlinfo.first?.url as! NSURL
    
    }
    
    func scene(_ scene: UIScene, openURLContexts URLContexts: Set) {
    
        let url = URLContexts.first!.url as NSURL
    
    }
    
    
    0 讨论(0)
  • 2021-01-17 11:14

    My situation was that the openURL extra function provided in the SceneDelegate was not being called after returning from Facebook Authentication.

    The solution was using

    .onOpenURL { (url) in
                    ApplicationDelegate.shared.application(
                        UIApplication.shared,
                        open: url,
                        sourceApplication: nil,
                        annotation: [UIApplication.OpenURLOptionsKey.annotation]
                    )
                }
    

    To call the function in my extra application delegate, which then worked properly.

    0 讨论(0)
  • 2021-01-17 11:33

    I had the same problem, and the method scene(_ scene:, continue userActivity:) was only called when the app is open.

    When I checked the connectionOptions passed to the method scene(_ scene:, willConnectTo session, options connectionOptions:) it had a user activity with the expected URL. So, I ended up calling the first method manually:

    func scene(_ scene: UIScene,
               willConnectTo session: UISceneSession,
               options connectionOptions: UIScene.ConnectionOptions) {
    
        if let userActivity = connectionOptions.userActivities.first {
            self.scene(scene, continue: userActivity)
        }
    }
    
    0 讨论(0)
提交回复
热议问题