如何在iOS9中从Safari打开URL方案? [英] How to open URL schemes from Safari in iOS9?
问题描述
我能够以这种方式从safari打开应用程序:
I was able to open apps from safari this way:
window.location = 'myapp://do/xx';
或打开Facebook应用程序:
or open facebook app:
window.location = 'fb://';
但这已停止在iOS9中运行。
But this stopped working in iOS9.
如何在Safari中使用URL方案打开应用程序?
How can I open apps using URL schemes in safari?
推荐答案
IOS 9 URL Shchemes更新:
iOS 9介绍LSApplicationQueriesSchemes允许应用程序查询是否安装了其他应用程序。
IOS 9 URL Shchemes Update : iOS 9 introduces LSApplicationQueriesSchemes to allow apps to query if other apps are installed.
1-如果声明了url方案并且调用了canOpenURL(方案)
1- If a url scheme is declared and calling canOpenURL(scheme)
如果安装的应用程序支持该URL方案
YES if a installed app supports that URL scheme
如果没有支持该URL的应用程序
NO if no app supporting that url
syslog将显示canOpenURL:URL失败:否urlScheme:// - 错误:null
syslog will show canOpenURL: failed for URL: "urlScheme://" - error: null
2-如果未声明url方案并且调用canOpenURL(方案)
2- If a url scheme is not declared and calling canOpenURL(scheme)
始终返回NO
syslog将显示canOpenURL:URL失败:urlScheme:// - 错误:null
syslog will show canOpenURL: failed for URL: "urlScheme://" - error: null
在iOS 9中,开发人员必须添加这些info.plist
LSApplicationQueriesSchemes
In iOS 9, the developer must add these info.plist LSApplicationQueriesSchemes
<array>
<string>urlscheme</string>
<string>urlscheme2</string>
<string>urlscheme3</string>
<string>urlscheme4</string>
</array>
最多50美元可以声明unqiue URL方案!
50 max. unqiue URL scheme can be declared!
这篇关于如何在iOS9中从Safari打开URL方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!