Apple: Detect missing bundle identifier when using location permissions

The location permissions database in /var/db/locationd/clients.plist
ties the location permission to the bundle identifier (among other
things), so a missing bundle identifier will result in the app asking
repeatedly for the location permission, as the permission is never
saved.

Change-Id: I64ab5b8f8762804869c0f97debd97da817787808
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit ad42833d3373604eec885702f1bc4719593d7dcf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2023-02-02 15:17:56 +01:00 committed by Qt Cherry-pick Bot
parent cd16380e09
commit 55e6278e3d

View File

@ -66,6 +66,13 @@ struct PermissionRequest
- (Qt::PermissionStatus)authorizationStatus:(QLocationPermission)permission
{
NSString *bundleIdentifier = NSBundle.mainBundle.bundleIdentifier;
if (!bundleIdentifier || !bundleIdentifier.length) {
qCWarning(lcLocationPermission) << "Missing bundle identifier"
<< "in Info.plist. Can not use location permissions.";
return Qt::PermissionStatus::Denied;
}
switch ([self authorizationStatus]) {
case kCLAuthorizationStatusRestricted:
case kCLAuthorizationStatusDenied: