Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String #2

Open
AlasKuNull opened this issue Nov 15, 2019 · 0 comments
Open

Comments

@AlasKuNull
Copy link

application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:])

方法中的:

urlKey:String = options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String

在iOS13中会闪退
原因是空对象强制解包.
解决方法:

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        if let urlKey:String = options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String {
        
        if urlKey == "com.tencent.xin"
        {
            // 微信 的回调
            return LDWechatShare.handle(url)
        } else if urlKey == "com.tencent.mqq"
        {
            
            // QQ 的回调
            return LDTencentShare.handle(url)
        } else if urlKey == "com.sina.weibo"
        {
            // 新浪微博 的回调
            return LDSinaShare.handle(url)
        }
        }
        if url.absoluteString.hasPrefix("tencentxxxxxxxxx") { // qq
            return LDTencentShare.handle(url)

        }else if url.absoluteString.hasPrefix("wbxxxxxxx") { // weibo
            return LDSinaShare.handle(url)

        }else if url.absoluteString.hasPrefix("wxxxxxxxxxx") { // wexin
            return LDWechatShare.handle(url)

        }
        return true
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant