• iOS:你App的设置做对了吗?


    http://www.cocoachina.com/ios/20151217/14707.html

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

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

    IMG_4808-577x1024.png

    我现在以一个心情沮丧用户的身份写这个帖子,希望更多的iOS开发者能与用户设置建立直接的深层链接,尤其是操作起来也非常容易。

    以下是一个日历相关的应用程序的警告提醒代码,其中包含了为用户进行设置的选项。我正试图在其中包含一个能将用户带入设置的选项。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    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中就能实现与用户设置进行深层链接

    1
    2
    3
    if let appSettings = NSURL(string: UIApplicationOpenSettingsURLString) {
        UIApplication.sharedApplication().openURL(appSettings)
    }

    当用户拒绝了授权,这就更像Swarm应用程序了。

    当用户点击“打开设置”时,他们就能很方便地进入这个界面。

    IMG_4811-577x1024.png

    只需添加这三行代码,就能在激活APP使用权限这一重要方面提高用户体验。以我为例,用户甚至会因为日历未被授权而不能继续使用应用程序。因此,我最大的兴趣就是让用户更改设置中的权限变得简单易行。同样,这也适用于许多其他的应用程序。

    IMG_4812.png

    注意:网友@jl_hfl指出,这一方法在iOS 9系统中的应用效果更好!设置界面中将有一个返回按钮,能直接使用户返回到您的应用程序。真没理由不用这个方法啊!

     
     
  • 相关阅读:
    继承中的虚函数、纯虚函数、普通函数
    struct与class的区别
    boost::filesystem总结
    ASM: Active Shape Models--Their Training and Application
    基础知识:仿射变换、相似变换、等距变换等常见变换
    PDM:Training Models of Shape from Sets of Examples
    常见优化器
    深度学习基础(五)ResNet_Deep Residual Learning for Image Recognition
    深度学习基础(四) Dropout_Improving neural networks by preventing co-adaptation of feature detectors
    ios 各种变量和作用范围
  • 原文地址:https://www.cnblogs.com/itlover2013/p/5066987.html
Copyright © 2020-2023  润新知