Skip to content

Commit

Permalink
Permission updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Dec 20, 2023
1 parent a2f3c99 commit d91bd4f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public async Task<AccessState> RequestAccess()
var result = await this.platform
.RequestFilteredPermissions(
new(P.ForegroundService, 31, null),
new(AndroidPermissions.PostNotifications, 33, null) // this isn't required - we ask to be nice
new(P.PostNotifications, 33, null) // this isn't required - we ask to be nice
)
.ToTask();

Expand Down
5 changes: 3 additions & 2 deletions src/Shiny.Core/Platforms/Android/AndroidPermission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public record AndroidPermission(
/// </summary>
public static class AndroidPermissions
{
//Manifest.Permission.PostNotifications
public const string PostNotifications = "android.permission.POST_NOTIFICATIONS";
//Manifest.Permission.PostNotifications
//public const string PostNotifications = "android.permission.POST_NOTIFICATIONS";
public const string ForegroundServiceLocation = "android.permission.FOREGROUND_SERVICE_LOCATION";
}
2 changes: 1 addition & 1 deletion src/Shiny.Core/Platforms/Android/AndroidPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public async Task<AccessState> RequestForegroundServicePermissions()
{
var results = await this.RequestPermissions(
Manifest.Permission.ForegroundService,
AndroidPermissions.PostNotifications
Manifest.Permission.PostNotifications
);
if (results.IsSuccess())
return AccessState.Available;
Expand Down
4 changes: 2 additions & 2 deletions src/Shiny.Locations/Platforms/Android/AbstractGpsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ protected virtual List<string> GetPermissionSet(GpsRequest request)
permissionSet.Add(P.ForegroundService);

if (OperatingSystemShim.IsAndroidVersionAtLeast(33))
permissionSet.Add(AndroidPermissions.PostNotifications);
permissionSet.Add(P.PostNotifications);

if (OperatingSystemShim.IsAndroidVersionAtLeast(34))
permissionSet.Add(P.ForegroundServiceLocation);
permissionSet.Add(AndroidPermissions.ForegroundServiceLocation);
break;
}
if (requestBg && OperatingSystemShim.IsAndroidVersionAtLeast(29))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public async Task<AccessState> RequestAccess(AccessRequestFlags access)
var list = new List<string>();

if (OperatingSystemShim.IsAndroidVersionAtLeast(33))
list.Add(AndroidPermissions.PostNotifications); // required
list.Add(P.PostNotifications); // required

if (OperatingSystemShim.IsAndroidVersionAtLeast(31) && access.HasFlag(AccessRequestFlags.TimeSensitivity))
list.Add(P.ScheduleExactAlarm); // if denied, restricted
Expand All @@ -109,7 +109,7 @@ public async Task<AccessState> RequestAccess(AccessRequestFlags access)
list.AddRange(new[] { P.AccessCoarseLocation, P.AccessFineLocation }); // required, along with access bg

var result = await this.platform.RequestPermissions(list.ToArray()).ToTask();
if (list.Contains(AndroidPermissions.PostNotifications) && !result.IsGranted(AndroidPermissions.PostNotifications))
if (list.Contains(P.PostNotifications) && !result.IsGranted(P.PostNotifications))
return AccessState.Denied;

if (access.HasFlag(AccessRequestFlags.LocationAware))
Expand Down
3 changes: 2 additions & 1 deletion src/Shiny.Push/Platforms/Android/PushManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Reactive.Threading.Tasks;
using System.Threading;
using System.Threading.Tasks;
using Android;
using Android.App;
using Android.Content;
using Android.Gms.Extensions;
Expand Down Expand Up @@ -111,7 +112,7 @@ public async Task<PushAccessState> RequestAccess(CancellationToken cancelToken =
if (OperatingSystemShim.IsAndroidVersionAtLeast(33))
{
var access = await this.platform
.RequestAccess(AndroidPermissions.PostNotifications)
.RequestAccess(Manifest.Permission.PostNotifications)
.ToTask(cancelToken);

if (access != AccessState.Available)
Expand Down

0 comments on commit d91bd4f

Please sign in to comment.