Table of Content

相信很多小伙伴即将开始着手 iOS 9 的适配工作了,下面我们就来了解一下 iOS 9 的一项新特性: URLScheme

URLScheme 白名单与 canOpenURL: 方法

在 iOS 9 中,苹果针对 URLScheme 又引入了新的白名单概念,在 WWDC 2015 Session 703: Privacy and Your App 中提到:

If you call the “canOpenURL” method on a URL that is not in your whitelist, it will return “NO”, even if there is an app installed that has registered to handle this scheme. A “This app is not allowed to query for scheme xxx” syslog entry will appear.

如果在 iOS 9 中调用 canOpenURL: 方法,则所涉及的 URLScheme 必须在 Info.plist 中列入白名单才能使用,否则该方法会返回 NO



WWDC 2015 Session 703: Privacy and Your App 还有这样一段话:

So for apps that are linked before iOS 9 and are running on iOS 9, they will be given 50 distinct URL schemes.


此外在iOS 9 中另外一个方法 openURL: 也增加了一个 UIAlertView 形式的确认动作。