出现此错误:条件绑定的初始化程序必须具有Optional类型,而不是'Bool'

时间:2018-11-20 10:32:14

标签: ios swift firebase firebase-dynamic-links

func application(_ app: UIApplication, open url: URL, options:
        [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

        if let isDynamicLink = DynamicLinks.dynamicLinks() .shouldHandleDynamicLink(fromCustomSchemeURL: url) {
            let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url)
            return handleDynamicLink(dynamicLink)
        }
        return true
    }

1 个答案:

答案 0 :(得分:4)

shouldHandleDynamicLink

⌥单击,您将看到声明

func shouldHandleDynamicLink(fromCustomSchemeURL url: URL) -> Bool

返回类型是非可选的。删除可选的绑定

func application(_ app: UIApplication, open url: URL, options:
    [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

    if DynamicLinks.dynamicLinks().shouldHandleDynamicLink(fromCustomSchemeURL: url) {
        let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url)
        return handleDynamicLink(dynamicLink)
    }
    return true
}