iOS: 13 Location Always Allow: After tapping on Open Settings, it does not redirect to App Settings page

Viewed 188

I need to open my application settings but sometime if we have opened setting other screen as like wifi or proxy screen then it does not redirect to App's settings in iOS 13.

@IBAction func openPhoneSettings(_ sender: Any) {
    guard let settingsUrl = URL(string: UIApplication.openSettingsURLString),
        UIApplication.shared.canOpenURL(settingsUrl) else {
            return
    }

    UIApplication.shared.open(settingsUrl, options: [:]) { (canOpen) in
        self.dismiss(animated: false, completion: nil)
    }
}
2 Answers

I made function for open App Setting, this work for me in all case to redirect to app setting

func openAppSetting()
{
   guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {return}

   if UIApplication.shared.canOpenURL(settingsUrl) 
   {
      if #available(iOS 10.0, *) 
      {
          UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
                        print("Settings opened: \(success)")
                    })
      } 
      else 
      {
         UIApplication.shared.openURL(settingsUrl as URL)
      }
   } 
   else 
   {
       print("Settings not opened")
   }
}

I Hope this will help...!

This works fine in my app, build for iOS 12 and later, tested on the simulator and real devices

UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)
Related