OGeek|极客世界-中国程序员成长平台

标题: ios - 如何在 iOS 9 中从电子邮件 URL 打开应用程序? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 17:27
标题: ios - 如何在 iOS 9 中从电子邮件 URL 打开应用程序?

我尝试过类似的方法:

在 AppDelegate 中:

func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool {
    var returnValue = false
    let urlString = url.absoluteString
    print(urlString)
    if(urlString.hasPrefix("")){
        returnValue = true
    }
    return returnValue
}

在 info.plist 中

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>co.example.ExampleApp</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>example</string>
        </array>
    </dict>
</array>

但不起作用。我希望通过我通过电子邮件发送的链接打开应用程序,有人有想法让它工作吗?



Best Answer-推荐答案


对于 future 的用户,正如@iSashok 在评论中提到的,handleOpenURL 函数 is deprecated as of iOS 9 .

对于较新版本的 iOS,您需要使用以下函数 (Apple Docs):

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

您将能够保持函数的主体与以前相同,现在它可以工作了。

关于ios - 如何在 iOS 9 中从电子邮件 URL 打开应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39371601/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4