Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Unable to Grant ScheduleExactAlarm permission. #2127

Open
munkii opened this issue Feb 21, 2024 · 0 comments
Open

Unable to Grant ScheduleExactAlarm permission. #2127

munkii opened this issue Feb 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@munkii
Copy link
Contributor

munkii commented Feb 21, 2024

Description

Android 12 introduced the ScheduleExactAlarm permission and to get access that to that in Andorid 12,13 and 14 I have written a custom Permission as per the "extending" docs.

   public interface IScheduleExactNotificationPermission
   {
       Task<PermissionStatus> CheckStatusAsync();

       Task<PermissionStatus> RequestAsync();
   }

With an implementation in Android of

public class ScheduleExactNotificationPermission : BasePlatformPermission, IScheduleExactNotificationPermission
{
  public override (string androidPermission, bool isRuntime)[] RequiredPermissions => new List<(string androidPermission, bool isRuntime)>
  {
      (Android.Manifest.Permission.ScheduleExactAlarm, true),
  }.ToArray();
}

AssemblyInfo.cs in Adroid target has these two permission declarations

[assembly: UsesPermission(Android.Manifest.Permission.ScheduleExactAlarm)]
[assembly: UsesPermission(Android.Manifest.Permission.UseExactAlarm)]

Steps to Reproduce

  1. In our common code I call it like this,
var status = await this.scheduleExactNotificationPermission.CheckStatusAsync();
if (status != PermissionStatus.Granted)
{
    status = await this.scheduleExactNotificationPermission.RequestAsync();
}
  1. In Android 12 status is Granted, Android 13 Granted but in Android 14 status is Denied after the call to RequestAccess. As I understand it the permission only had to be requested from Android 14 onwards.

Expected Behavior

An OS Dialog that allows me as a user to Grant permission

Actual Behavior

Nothing other than an immediate call back into OnRequestPermissionsResult with the following args
requestCode 12001
permissions android.permission.SCHEDULE_EXACT_ALARM
grantResults -1

This happens on a fresh install too so is not simply becvause it has been asked many times before and denied

Basic Information

  • Version with issue: Xamarin Essentials 1.8.1
  • Last known good version: New code
  • IDE: VS2022 17.9.0
  • Platform Target Frameworks:
    • iOS:
    • Android: 33
    • UWP:
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:

Screenshots

Reproduction Link

@munkii munkii added the bug Something isn't working label Feb 21, 2024
@munkii munkii changed the title No OS dialog when requesting ScheduleExactAlarm permission. Unable to Grant ScheduleExactAlarm permission. Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant