Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

iOS LocationAlways doesn't popup an iOS permission dialog with "Always" as an option. Plugin returns Granted but iOS settings shows "When In Use" (not Always) #163

Open
RobbiewOnline opened this issue Jan 7, 2020 · 3 comments

Comments

@RobbiewOnline
Copy link

RobbiewOnline commented Jan 7, 2020

Bug Information

Version Number of Plugin: 3.0.0.12
Device Tested On:
Simulator Tested On: iOS Simulator (iOS 13)
Version of VS: 8.3.11 build 1 (Mac)
Version of Xamarin:Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5b)
Versions of other things you are using:

Version: 13.6.0.12 (Visual Studio Community)

Steps to reproduce the Behavior

  • Start from a clean simulator (Hardware -> Erase all contents and settings)
  • Run the code snippet below

Expected Behavior

  • Requesting 'When in use" should prompt a permission dialog
  • Requesting 'Always Use' should prompt a permission dialog
  • iOS App Settings should mirror requested permissions

Actual Behavior

  • Requesting 'Always Use' does NOT show an iOS permission dialog
  • iOS app Settings remain as "When in use" and doesn't show "Always"
  • Querying CheckPermissionStatusAsync(Permission.LocationWhenInUse) yields Granted which doesn't match iOS app settings

Code snippet

// Part 1 - check both permissions are 'unknown'
var locationWhenInUse = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.LocationWhenInUse);
var locationAlways = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.LocationAlways);

// Part 2 - Request 'WhenInUse'
var dict = await CrossPermissions.Current.RequestPermissionsAsync(Permission.LocationWhenInUse);

// Part 3 - Verify WhenInUse is granted
locationWhenInUse = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.LocationWhenInUse); // Granted
locationAlways = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.LocationAlways); // Denied

// Part 4 - Attempt requesting 'LocationAlways' - reports granted but not reflected in Settings -> App
dict = await CrossPermissions.Current.RequestPermissionsAsync(Permission.LocationAlways); // Returns Granted
locationWhenInUse = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.LocationWhenInUse);
locationAlways = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.LocationAlways); // Returns Granted

// Part 5 - repeat the above and step 1 will show granted for In Use and Always scenarios but iOS settings only for In Use.

I have also tried Permission.Location which auto-complete comments that it's the equivalent of LocationWhenInUse and LocationAlways, but still iOS doesn't prompt for the 'Always' permission, however if the app is collecting location data then eventually it does popup in the background which seems very late to ask for the allow always permission. Shouldn't it allow me to explicitly request it from the user before I start using it?

175d02e4-c625-437c-86ae-cc18a894bd66

Debugging Screenshots

When reviewing the permissions the plugin says both LocationWhenInUse and LocationAlways are granted

But iOS settings doesn't concur

Re-running the app will yield granted for both in part 1

Summary

1 - Shouldn't requesting the LocationAlways permission explicitly ask the iOS user immediately? It currently asks after the app has been backgrounded for some time.

2 - Why doesn't iOS settings reflect the same as CheckPermissionStatusAsync(Permission.LocationAlways)

A useful link is https://medium.com/rakutenready/requesting-location-permissions-in-ios-9e5a3b814a8b which explains how the common approach is to request the "When In Use" location permission first and then ask the user to upgrade to "Use Always" as a later step.

I'm not sure whether this library isn't invoking something correctly, or whether iOS doesn't present the user with the "Always" option unless the app has been running in the background for a while?

@RobbiewOnline RobbiewOnline changed the title iOS LocationWhenInUse v LocationAlways iOS LocationAlways doesn't popup an iOS permission dialog with "Always" as an option, but says "Granted" when iOS settings only shows "When In Use" (not Always). Jan 7, 2020
@RobbiewOnline RobbiewOnline changed the title iOS LocationAlways doesn't popup an iOS permission dialog with "Always" as an option, but says "Granted" when iOS settings only shows "When In Use" (not Always). iOS LocationAlways doesn't popup an iOS permission dialog with "Always" as an option. Plugin returns Granted but iOS settings shows "When In Use" (not Always) Jan 7, 2020
@RobbiewOnline
Copy link
Author

@jamesmontemagno could you please confirm whether this is a bug or intended iOS behaviour? Thank you.

@RamonFarizel
Copy link

I think it's a intended behavior on IOS 13.

The existing “Allow While Using App” option will grant location permissions to users in the foreground just as it has in the past. However, if an app’s developers have additionally requested that the app track background location, then selecting this option will additionally grant provisional “Always Allow” permissions. This means that the app is actually granted permission to request the user’s location data while the app is not actively visible on the screen for a short period of time. During this short period, Apple will be keeping track of that usage, and eventually will prompt the user with the following: “Keep Only While Using” or “Change to Always Allow.” The notice includes a customizable subtext explaining why the app needs “Always Allow” location permission and helps users understand why and how the location is used to deliver value

Please, checkout this explanation

@RobbiewOnline
Copy link
Author

Please, checkout this explanation

Thank you @RamonFarizel this now makes much more sense!

@jamesmontemagno could you consider adding this explanation to the plugin documentation for other users to discover the behaviour?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants