zoukankan      html  css  js  c++  java
  • App的设置

    iOS 8及以上版本最不为人知的一个特点是与应用设置的深层链接,用户可以根据APP的需要授权启用位置、通知、联系人、相机、日历以及健康等设置。

    大多数应用程序仅仅是弹出一个包含操作指令的警示窗口,如“进入设置>隐私>位置>OUR_APP”。例如,推特的应用程序有一个更为精致和友好的指示对话框,所以我就把它当做一个例子来使用。

    希望更多的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使用权限这一重要方面提高用户体验。以我为例,用户甚至会因为日历未被授权而不能继续使用应用程序。因此,我最大的兴趣就是让用户更改设置中的权限变得简单易行。同样,这也适用于许多其他的应用程序。

  • 相关阅读:
    day23 笔记
    iframe子页面与父页面通信
    js格式化时间
    自定义滚动条样式
    表格隔行换色
    css除第一个子元素的其他子元素的4种方法,超实用!
    子div在父div里居中
    红橙黄绿蓝靛紫-RGB-十六进制
    阿里巴巴矢量图标库 字体图标的下载与使用
    calc属性不生效
  • 原文地址:https://www.cnblogs.com/zhangz-1511/p/5080884.html
Copyright © 2011-2022 走看看