iOS: Disallow upgrading QLocationPermission::WhenInUse to Always
This is technically possible on iOS, but the system doesn't give us a callback unless the user accepts the upgraded permission level, and we need a deterministic callback in both cases so that we can report the result back to the permission request callback. https://tinyurl.com/requestalwaysauthorization Change-Id: Id006dbbb2f6fad4b831742e4d3e904525aaa8a2a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 8dc3ee03a42ccb1b047c2a8f34b5bce4e663c9d9) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
ac0238478a
commit
b99f9c50c0
@ -83,10 +83,9 @@ struct PermissionRequest
|
|||||||
return Qt::PermissionStatus::Granted;
|
return Qt::PermissionStatus::Granted;
|
||||||
#ifdef Q_OS_IOS
|
#ifdef Q_OS_IOS
|
||||||
case kCLAuthorizationStatusAuthorizedWhenInUse:
|
case kCLAuthorizationStatusAuthorizedWhenInUse:
|
||||||
if (permission.availability() == QLocationPermission::WhenInUse)
|
if (permission.availability() == QLocationPermission::Always)
|
||||||
return Qt::PermissionStatus::Granted;
|
return Qt::PermissionStatus::Denied;
|
||||||
else
|
return Qt::PermissionStatus::Granted;
|
||||||
return Qt::PermissionStatus::Denied; // FIXME: Verify
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,11 +175,20 @@ struct PermissionRequest
|
|||||||
// or authorized when in use.
|
// or authorized when in use.
|
||||||
switch ([self authorizationStatus]) {
|
switch ([self authorizationStatus]) {
|
||||||
case kCLAuthorizationStatusNotDetermined:
|
case kCLAuthorizationStatusNotDetermined:
|
||||||
#ifdef Q_OS_IOS
|
|
||||||
case kCLAuthorizationStatusAuthorizedWhenInUse:
|
|
||||||
#endif
|
|
||||||
[self.manager requestAlwaysAuthorization];
|
[self.manager requestAlwaysAuthorization];
|
||||||
break;
|
break;
|
||||||
|
#ifdef Q_OS_IOS
|
||||||
|
case kCLAuthorizationStatusAuthorizedWhenInUse:
|
||||||
|
// Unfortunately when asking for AlwaysAuthorization when in
|
||||||
|
// the WhenInUse state, to "upgrade" the permission, the iOS
|
||||||
|
// location system will not give us a callback if the user
|
||||||
|
// denies the request, leaving us hanging without a way to
|
||||||
|
// respond to the permission request.
|
||||||
|
qCWarning(lcLocationPermission) << "QLocationPermission::WhenInUse"
|
||||||
|
<< "can not be upgraded to QLocationPermission::Always on iOS."
|
||||||
|
<< "Please request QLocationPermission::Always directly.";
|
||||||
|
Q_FALLTHROUGH();
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
[self deliverResult];
|
[self deliverResult];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user