iOS 9 中是否有替代(已弃用的)canOpenURL 的方法?

Is there an alternative to (the deprecated) canOpenURL in iOS 9?

我正在使用苹果的 canOpenURL: 和 openURL: 方法来检测和打开其他应用程序。但由于这些方法在 iOS9 中已被弃用,它们 returns NO.

是否有任何替代方法可以解决这个问题?

谢谢

Here你可以找到一些资料。

正如文章所说:

Up until iOS 9, apps have been able to call these methods on any arbitrary URLs. Starting on iOS 9, apps will have to declare what URL schemes they would like to be able to check for and open in the configuration files of the app as it is submitted to Apple. This is essentially a whitelist that can only be changed or added to by submitting an update to Apple. It appears that certain common URLs handled by system apps, like “http”, “https”, do not need to be explicitly whitelisted.

简而言之:Apple 希望阻止应用程序扫描用户的设备并知道安装了哪些应用程序

所以回答你的问题:实际上没有解决方案,因为苹果正是想防止这种行为

您需要将 "whitelist" 提供给您的 plist

<key>LSApplicationQueriesSchemes</key>
<array>
 <string>urlscheme</string>
 <string>urlscheme2</string>
 <string>urlscheme3</string>
 <string>urlscheme4</string>
</array> 

查看更多详情

More details

在某些情况下,如果您需要打开任意深层链接,Universal App Links 可能是一个解决方案:您指向应用程序的网站(需要实现此行为)和 iOS 9 将自动深层链接到临时应用程序。