我能够通过这种方式从 safari 打开应用程序:
window.location = 'myapp://do/xx';
或打开 Facebook 应用程序:
window.location = 'fb://';
但这在 iOS9 中停止工作了。
如何在 Safari 中使用 URL 方案打开应用程序?
最佳答案
IOS 9 URL Shchemes 更新: iOS 9 引入了 LSApplicationQueriesSchemes 以允许应用程序查询是否安装了其他应用程序。
1- 如果声明了 url scheme 并调用 canOpenURL(scheme)
如果安装的应用程序支持该 URL 方案,则为 YES
如果没有应用支持该 url,则否
syslog 将显示 canOpenURL: failed for URL: "urlScheme://"- error: null
2- 如果未声明 url scheme 并调用 canOpenURL(scheme)
总是返回NO
syslog 将显示 canOpenURL: failed for URL: "urlScheme://"- error: null
在 iOS 9 中,开发者必须添加这些 info.plist LSApplicationQueriesSchemes
<array>
<string>urlscheme</string>
<string>urlscheme2</string>
<string>urlscheme3</string>
<string>urlscheme4</string>
</array>
最多 50 个可以声明独特的 URL 方案!
关于ios - 如何在 iOS9 中从 Safari 打开 URL 方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31361655/