Hi @ericD_TRI ,
Yep, that's expected behavior. Once it's denied by the user in settings, you'll need to handle that case in your code when you check if the user is authorized. I'd do something like this:
func setUpSession() async {
// If we have the required authorizations immediately run the session
let authRes = await session.queryAuthorization(for: HandTrackingProvider.requiredAuthorizations)
if hasRequiredAuthorizations(authorizationResult: authRes) {
await start()
} else {
// else request the required authorizations
let requestedResult = await session.requestAuthorization(for: HandTrackingProvider.requiredAuthorizations)
if requestedResult.allSatisfy( { $0.value == .denied } ) {
// Here, you would open a new window with this id that mentions that the user needs to go to Settings and allow the hand tracking.
openWindow(id: “permissionDenied”)
}
// and if the user grants them, run the session.
if hasRequiredAuthorizations(authorizationResult: requestedResult) {
await start()
}
}
}
func hasRequiredAuthorizations(authorizationResult: [ARKitSession.AuthorizationType : ARKitSession.AuthorizationStatus]) -> Bool {
HandTrackingProvider.requiredAuthorizations
.map { authorizationResult[$0] ?? ARKitSession.AuthorizationStatus.notDetermined }
.allSatisfy { $0 == .allowed }
}
This snippet uses openWindow to open a window telling the user to go to setting and turn back on the toggle. You can also use Link
to send them straight to settings in the new window:
Link("go to settings", destination: URL(string: UIApplication.openSettingsURLString)!)
Clicking this will take them to your app's settings.