我现在以一个心情沮丧用户的身份写这个帖子,希望更多的iOS开发者能与用户设置建立直接的深层链接,尤其是操作起来也非常容易。
以下是一个日历相关的应用程序的警告提醒代码,其中包含了为用户进行设置的选项。我正试图在其中包含一个能将用户带入设置的选项。
func showEventsAcessDeniedAlert() {let alertController = UIAlertController(title: "Sad Face Emoji!",message: "The calendar permission was not authorized. Please enable it in Settings to continue.",preferredStyle: .Alert)let settingsAction = UIAlertAction(title: "Settings", style: .Default) { (alertAction) in// THIS IS WHERE THE MAGIC HAPPENS!!!!if let appSettings = NSURL(string: UIApplicationOpenSettingsURLString) {UIApplication.sharedApplication().openURL(appSettings)}}alertController.addAction(settingsAction)let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)alertController.addAction(cancelAction)presentViewController(alertController, animated: true, completion: nil)}再次提醒,仅需要添加此代码到您的APP中就能实现与用户设置进行深层链接
if let appSettings = NSURL(string: UIApplicationOpenSettingsURLString) {UIApplication.sharedApplication().openURL(appSettings)}当用户拒绝了授权,这就更像Swarm应用程序了。
只需添加这三行代码,就能在激活APP使用权限这一重要方面提高用户体验。以我为例,用户甚至会因为日历未被授权而不能继续使用应用程序。因此,我最大的兴趣就是让用户更改设置中的权限变得简单易行。同样,这也适用于许多其他的应用程序。
这一方法在iOS 9系统中的应用效果更好!设置界面中将有一个返回按钮,能直接使用户返回到您的应用程序。真没理由不用这个方法啊!
以上内容是小编简单给大家介绍的IOS提醒用户重新授权打开定位功能的全部叙述,希望大家喜欢。