Problem with openSettingsURLString

Hello,


Sometimes, this piece of code opens iPhone Settings (instead of app Settings)


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


But other times, it opens app settings, as the documentation says.

(I am using iPhone X and iOS 12)


I think the reason is that when the app does not appear in the settings list (because it is the first time that app is exectured), then openURL does not know how to open app settings (because it does not exist) and opens iphone settings. To test that, create an app with those 2 lines of code. And remember to reset the simulator entirely to test the wrong case.


Do you have or see the same problem?


Thanks a lot.

hello ricardo


i am experiencing the same bug.. very frustrating. did you find a solution? apple has no response to this issue apparently?

I'm having the same issue and I found out the reason, at first launch if the app didn't asking a user for any kind of permission (Access Location, receive notifications.. etc) app is not listed in iPhone Settings.

But after asking a permission from user app is listed.

This is why app some times (after first launch) is showing iPhone Settings rather than app settings.

I'm still looking for work around for this issue.
I'm experiencing the same behavior. After the user denies the permission request, the app displays an 'Open Settings' button. On the first tap, the button opens Settings, but not the application settings page. On returning to my app and tapping the button again, it correctly goes to the application settings page.

Is there a way to prevent this from happening?

Hello, I am currently facing a similar issue. Did anyone get a solution for this?

Also currently experiencing the same issue

It looks like it goes to whatever settings you last examined.

this is still happening .... Is there a way to prevent this from happening?

Hi, everyone

I found solution. You need to use bundle identifier in url. My Xcode 15.0, Swift 5.9.

guard let bundleId = Bundle.main.bundleIdentifier,
      let settingsUrl = URL(string: "\(UIApplication.openSettingsURLString)/\(bundleId)") else {
    return
}

I'm having the same problem. The solution to add the bundleIdentifier didn't fix it for me I'm afraid. :(

no solution till now. On some devices problem is reproduced but on some device problem persist.

Problem with openSettingsURLString
 
 
Q