UIApplicationOpenURLOptionsKey.sourceApplication可以为零吗?

时间:2017-12-27 07:10:35

标签: ios swift swift4

最近在新的应用更新后,我们开始崩溃

let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String

在以下代码中。我只是想知道为什么它可以是零或因为as而崩溃!字符串?

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
    CoreAnalytics.shared.record("AppDelegate", action: "Open URL")
    Branch.getInstance().handleDeepLink(url)
    let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String
    let annotation = options[UIApplicationOpenURLOptionsKey.annotation]

    CleverTap.sharedInstance()?.handleOpen(url, sourceApplication: sourceApplication)

    return
        GIDSignIn.sharedInstance().handle(url, sourceApplication: sourceApplication, annotation: annotation) ||
        FBSDKApplicationDelegate.sharedInstance().application(app, open: url, sourceApplication: sourceApplication, annotation: annotation)
}

1 个答案:

答案 0 :(得分:0)

这是从Apple钱包通行证打开应用程序时发生的。