Home > front end >  How to ask users to always use the 'precise location' option?
How to ask users to always use the 'precise location' option?

Time:07-11

enter image description here

Hello. I'm making an app that organizes the user's movement records when hiking. So I want to encourage users to use the Precise Location option all the time.

However, I saw a lot of pop-ups asking me to set location permissions on other apps, but I couldn't find a pop-up or UX asking me to turn on the Precise Location that was turned off. Is it against Apple's policy to ask for this?

If you don't violate it, I'd like to know how other apps ask users to turn on their permissions.

Thank you.

CodePudding user response:

You can kindly ask users to enable precise location by presenting an UIAlertController which will contain description why you need it for, and action to navigate to app settings. When they press the action you will navigate to app settings likewise:

func navigateToSystemSettings() {
    if let settingsUrl = URL(string: UIApplication.openSettingsURLString)  {
        if UIApplication.shared.canOpenURL(settingsUrl) {
            UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
                print("Settings opened: \(success)") // Prints true
            })
        }
    }
}

Presenting simple UIAlert:

func presentAlert() {
    let alert = UIAlertController(title: "Precise location", message: "Please enable precise location by tapping location -> precise location", preferredStyle: .alert)
    let action = UIAlertAction(title: "Navigate to settings", style: .default) { _ in
        self.navigateToSystemSettings()
    }
    alert.addAction(action)
    DispatchQueue.main.async {
        self.present(alert, animated: true)
    }
}

Also prior to displaying UIAlertController it would be nice to present some screenshot with some arrow pointing to "precise location" switch in settings, so it would be more clear what the user should do.

P.S. This navigateToSystemSettings() function should open your App settings. If it only opens the plain "Settings" instead, fix the issue by uploading app to testflight so that it appears among another apps that are presented on bottom of "Settings" app.

  • Related