0

I am developing an app for iOS, in which I have to check the GPS, whether 'Location Services' is off or not. If 'Location Services' is off, then I have to launch the Settings app with url "Settings->Privacy->Location Services", in which user can enable the 'Location Services'. For this I am using the following code

if let url = URL(string: "App-Prefs:root=Privacy&path=LOCATION")
        {
            if #available(iOS 10.0, *) {
                UIApplication.shared.open(url, options: [:], completionHandler: nil)
            }
            else
            {
                UIApplication.shared.openURL(url)
                // Fallback on earlier versions
            }
        }

But this will only launch the 'Settings' app with last active session of settings app not in 'Location Services'. I am using Swift 5 with Xcode 11 beta 2. I have listen about custom url scheme. But don't know how to use it properly. Please guide me for this.

Rohit Chauhan
  • 151
  • 1
  • 3
  • 14
  • possible duplicate of https://stackoverflow.com/questions/37654132/how-to-open-location-services-screen-from-setting-screen – Alexandr Kolesnik Jul 31 '19 at 07:47
  • Hii @AlexandrKolesnik thanks for reply, I have checked this question. The answer of the link which you comment, is work only for iOS 10 not in latest ios thats why I specially mentioned my os is iOS 12. This answer is not work with ios 11 onwards . – Rohit Chauhan Jul 31 '19 at 07:52
  • 1
    Be careful, your app can be rejected by Apple, because you're using the "App-Prefs". This is a private API which Apple doesn't allow to be used. All you can do is open own app's preferences. – Starsky Jul 31 '19 at 07:56
  • Hii @Starsky, thanks for the reply, I can use "App-Prefs", because I am not uploading this app on App Store. I will distribute it using Enterprise mode not in App Store mode. – Rohit Chauhan Jul 31 '19 at 08:09

0 Answers0