application openURL in Swift

前端 未结 3 769
囚心锁ツ
囚心锁ツ 2021-01-18 13:57

I am having an issue with the Appdelegate method OpenURL.

I have setup my Imported UTI\'s and Document Type. But when opening my app from a mail attachment, the app

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-18 14:55

    I have my head blow for a week with this issue.
    My app keep crashing after Login Using Social Media Such as Wechat / LinkedIn.But Facebook and Google Sign in Works Fine.

    I have notice my app will keep crash after confirm sign in on Wechat Apps and will enter foreground.and Getting BAD EXCESS error. I have try to remove my application open url method on AppDelegate and the app wont crash but the action for Social Media Login are not functioning. so I detect that my issue was on the specific method. after search the web I found that im using an deprecated method of ApplicationOpenUrl as reference from https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623073-application

    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return true
    } // this method is deprecated in iOS 9 https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623073-application
    

    notice that the deprecated version are using annotation:Any which will cause issue if you had bridging to an Obj-c framework such as wechat.
    So what I do was, I swap my code into a the new format

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String
        let annotation = options[UIApplicationOpenURLOptionsKey.annotation]
        let application = app
    
        return true
    }
    

    Hope this help. it will became my reference in feature also. thanks StackOverflow

提交回复
热议问题