8

I'm currently using Swift to write an independent Apple Watch app for watchOS 7+. My app uses Location Services, and in case the user doesn't allow that at first, I'd like to have a button inside my watchOS app to send my user to the part of the Settings app (inside watchOS) where he can give the appropriate permissions for the app.

I know that in iOS/macOS you can use the openSettingsURLString string from UIApplication to do what I want, but it's not available in watchOS and I haven't found any equivalent resource inside the WKExtension class (normally the equivalent for UIApplication in the watchOS environment, as discussed here).

Does anyone know if there's any way to programatically open the Apple Watch Settings app from my watchOS app?

The code below is what I'm trying to do - but (of course) it crashes since I'm not actually passing any systemURL.

.alert(isPresented: $alertVisible) {
                Alert (title: Text("Please allow our app to use location services in order to get Weather Data"),
                       message: Text("Go to Settings?"),
                       primaryButton: .default(Text("Settings"), action: {
                    WKExtension.shared().openSystemURL(URL(string: "")!)
                    //UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
                }),

  • You are not the only one who have to tackle exact this problem. Did you, by any chance, already find a solution? – Confused Merlin Nov 22 '21 at 12:59
  • I am afraid that "openSystemURL" is the wrong function... I tried "WKExtension.shared().openSystemURL(URL:(string:'prefs:root=WIFI')!)", but it says "URL with scheme "prefs" not supported" in log once I clickt the button with that action :( – Confused Merlin Nov 22 '21 at 13:54
  • I still don't have a solution. I posted the same question on the Apple Dev forums ([link](https://developer.apple.com/forums/thread/694269)), but no answer until now. Also tried sending a Feedback Request to Apple but still no answer either. :( I'll try sending one again this week and I suggest you do the same! To get over this right now I'm just showing a modal in my Watch app that basically says "Go to Settings > Location Services to change permissions". – Mateus Levi Nov 23 '21 at 13:04
  • Did you already find a solution? – Pjaks Aug 02 '22 at 12:27
  • @Pjaks unfortunately no. I actually had a talk with an Engineer at Apple and they couldn't really give me a definite answer, so I just left the solution I wrote above in the app. – Mateus Levi Sep 25 '22 at 23:36

0 Answers0