Sunday, November 09, 2014

Tip - Redirecting Users to the Setting Page (iOS 8)

In iOS, you often need to redirect the user to the Settings page. For example, if you detected that the user has turned off WiFi and your application needs to access the Internet using WiFi, you might want to automatically launch the Settings page so that the user can turn on the WiFi directly. In iOS 8, you can do so via the UIApplicationOpenSettingsURLString constant, like this:

        if UIApplicationOpenSettingsURLString != nil {
            var appSettings = NSURL(string: UIApplicationOpenSettingsURLString)
            UIApplication.sharedApplication().openURL(appSettings!)
        }


The above code snippet will redirect the user to the Settings page. 

No comments: