canOpenURL 始终 return false 即使我指定启动服务密钥
canOpenURL always return false even if I specify Launch Service Keys
我正在尝试检测是否安装了特定应用程序,根据文档,canOpenURL 方法可能有所帮助。我也在 iOS 11,根据文档,对于 > iOS 9,请记住这一点很重要:
Important If your app is linked on or after iOS 9.0, you must declare
the URL schemes you want to pass to this method. Do this by adding the
LSApplicationQueriesSchemes key to your app's Info.plist file. If you
call this method for a scheme not declared using that key, this method
always returns false, whether or not an appropriate app is installed.
To learn more about the key, see LSApplicationQueriesSchemes.
意味着在Info.plist
中,我应该添加这样的内容:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>messenger</string>
</array>
到目前为止,还不错。但是当我尝试检测是否安装了应用程序时,如下所示:
if( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"messenger://"]]){}
我仍然是假的...我在这里错过了什么?
Facebook Messenger 使用:
<string>fb-messenger-api</string>
作为其 URL 方案。
我正在尝试检测是否安装了特定应用程序,根据文档,canOpenURL 方法可能有所帮助。我也在 iOS 11,根据文档,对于 > iOS 9,请记住这一点很重要:
Important If your app is linked on or after iOS 9.0, you must declare the URL schemes you want to pass to this method. Do this by adding the LSApplicationQueriesSchemes key to your app's Info.plist file. If you call this method for a scheme not declared using that key, this method always returns false, whether or not an appropriate app is installed. To learn more about the key, see LSApplicationQueriesSchemes.
意味着在Info.plist
中,我应该添加这样的内容:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>messenger</string>
</array>
到目前为止,还不错。但是当我尝试检测是否安装了应用程序时,如下所示:
if( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"messenger://"]]){}
我仍然是假的...我在这里错过了什么?
Facebook Messenger 使用:
<string>fb-messenger-api</string>
作为其 URL 方案。