ios - 如何在 iOS 9 中从电子邮件 URL 打开应用程序?
<p><p>我尝试过类似的方法:</p>
<p>在 AppDelegate 中:</p>
<pre><code>func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool {
var returnValue = false
let urlString = url.absoluteString
print(urlString)
if(urlString.hasPrefix("")){
returnValue = true
}
return returnValue
}
</code></pre>
<p>在 info.plist 中</p>
<pre><code><key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>co.example.ExampleApp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>example</string>
</array>
</dict>
</array>
</code></pre>
<p>但不起作用。我希望通过我通过电子邮件发送的链接打开应用程序,有人有想法让它工作吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>对于 future 的用户,正如@iSashok 在评论中提到的,handleOpenURL 函数 <a href="https://developer.apple.com/reference/uikit/uiapplicationdelegate/1622964-application" rel="noreferrer noopener nofollow">is deprecated as of iOS 9</a> . </p>
<p>对于较新版本的 iOS,您需要使用以下函数 (<a href="https://developer.apple.com/reference/uikit/uiapplicationdelegate/1623112-application" rel="noreferrer noopener nofollow">Apple Docs</a>):</p>
<pre><code>optional func application(_ app: UIApplication,
open url: URL,
options: = [:]) -> Bool
</code></pre>
<p>您将能够保持函数的主体与以前相同,现在它可以工作了。</p></p>
<p style="font-size: 20px;">关于ios - 如何在 iOS 9 中从电子邮件 URL 打开应用程序?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/39371601/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/39371601/
</a>
</p>
页:
[1]