简体   繁体   中英

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

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)
    }
}

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...!

这在我的应用程序中运行良好,为 iOS 12 及更高版本构建,在模拟器和真实设备上测试

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM