Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android12 Notifee not correctly handling new REQUIRE_EXACT_ALARM permission #239

Closed
mikehardy opened this issue Nov 19, 2021 · 8 comments
Closed

Comments

@mikehardy
Copy link
Contributor

Saw this: https://developer.android.com/about/versions/12/behavior-changes-12#exact-alarm-permission

As I was working through #238 / unrelated Android12 behavior change

@mikehardy mikehardy changed the title Consider documenting / using 'exact alarm permission' from Android12 Android12 crash missing REQUIRE_EXACT_ALARM permission Nov 19, 2021
@mikehardy
Copy link
Contributor Author

Turns out this mandatory or you get a crash when setting triggers

mikehardy added a commit that referenced this issue Nov 19, 2021
…permission

Related #239
https://developer.android.com/about/versions/12/behavior-changes-12#exact-alarm-permission

Notifee still needs to:
-  expose platform API `canScheduleExactAlarms`
-  Intent ACTION_REQUEST_SCHEDULE_EXACT_ALARM to send users to settings screen and
-  ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED receiver to reschedule alarms
@mikehardy
Copy link
Contributor Author

My commit fixes the hard crash out of the box but if permission is revoked, it will still crash after

Notifee still needs to:

  • expose platform API canScheduleExactAlarms
  • Intent ACTION_REQUEST_SCHEDULE_EXACT_ALARM to send users to settings screen and
  • ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED receiver to reschedule alarms

@mikehardy
Copy link
Contributor Author

I have fixed the crashes by at least guarding trigger creation in case a user or the system removes it. This will show up in the logs if trigger settings was not possible:

11-19 16:11:26.677 22634 22776 W System.err: Missing SCHEDULE_EXACT_ALARM permission. Trigger not scheduled. Issue #239

This method: needs some way to propagate back through the call chain that it was unsuccessful but that is an API design question

static void scheduleTimestampTriggerNotification(

First goal is just to not crash

mikehardy added a commit that referenced this issue Nov 19, 2021
…permission

Related #239
https://developer.android.com/about/versions/12/behavior-changes-12#exact-alarm-permission

Notifee still needs handle these items:
-  warn API callers through promise rejection if scheduling a trigger was not possible
-  expose platform API `canScheduleExactAlarms`
-  Intent ACTION_REQUEST_SCHEDULE_EXACT_ALARM to send users to settings screen and
-  ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED receiver to reschedule alarms
mikehardy added a commit that referenced this issue Nov 19, 2021
…permission

Related #239
https://developer.android.com/about/versions/12/behavior-changes-12#exact-alarm-permission

Notifee still needs handle these items:
-  warn API callers through promise rejection if scheduling a trigger was not possible
-  expose platform API `canScheduleExactAlarms`
-  Intent ACTION_REQUEST_SCHEDULE_EXACT_ALARM to send users to settings screen and
-  ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED receiver to reschedule alarms
helenaford pushed a commit that referenced this issue Nov 20, 2021
…permission

Related #239
https://developer.android.com/about/versions/12/behavior-changes-12#exact-alarm-permission

Notifee still needs handle these items:
-  warn API callers through promise rejection if scheduling a trigger was not possible
-  expose platform API `canScheduleExactAlarms`
-  Intent ACTION_REQUEST_SCHEDULE_EXACT_ALARM to send users to settings screen and
-  ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED receiver to reschedule alarms
helenaford added a commit that referenced this issue Nov 20, 2021
…lag (#240)

* test(e2e): use android12 emulator image in CI

Related #238

* test(ci): run checks on all push events

without a constraint on minutes, we should run CI on any push
This gives CI support out of the box to developers working on code before
they make a pull request

* fix(android, API31): specify intent mutability / fix Android12 crash

See: https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability
Fixes #238

* fix(android, deps)!: use workmanager 2.7.1, requires minCompileSdk 31

This is required for Android 12 support, and fixes the crash noted in #240

* fix(android, triggers): avoid Android12 crash w/SCHEDULE_EXACT_ALARM permission

Related #239
https://developer.android.com/about/versions/12/behavior-changes-12#exact-alarm-permission

Notifee still needs handle these items:
-  warn API callers through promise rejection if scheduling a trigger was not possible
-  expose platform API `canScheduleExactAlarms`
-  Intent ACTION_REQUEST_SCHEDULE_EXACT_ALARM to send users to settings screen and
-  ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED receiver to reschedule alarms

* fix(android, deps): move permission to lib

Co-authored-by: Helena Ford <helenaellieford@gmail.com>
@helenaford
Copy link
Member

@mikehardy I believe this is fixed, right with v4.0.0? Can we close this?

@mikehardy mikehardy changed the title Android12 crash missing REQUIRE_EXACT_ALARM permission Android12 Notifee not correctly handling new REQUIRE_EXACT_ALARM permission Dec 11, 2021
@mikehardy
Copy link
Contributor Author

@helenaford I re-titled this, right now if the user removes the new permission via system settings Notifee will silently fail to set alarms. That's a major unexpected surprise for devs using the package I believe. And there are no methods exposed to allow devs to interrogate the state of the permission via the new Android 12 APIs, so it would be silent with no recourse. Until the permission for REQUIRE_EXACT_ALARM is handled more thoroughly I think this is an open issue

vincent-paing added a commit to vincent-paing/notifee that referenced this issue Mar 2, 2022
This allows consumer to check whether they can trigger
exact timestamp notifications for Android >= 12.

See: invertase#239
vincent-paing added a commit to vincent-paing/notifee that referenced this issue Mar 6, 2022
This allows consumer to check whether they can trigger
exact timestamp notifications for Android >= 12.

See: invertase#239
vincent-paing added a commit to vincent-paing/notifee that referenced this issue Mar 6, 2022
Will default resolve nothing in iOS and Android < 12. Otherwise,
open alarm and reminders permission settings for the app

See: invertase#239
@vincent-paing
Copy link
Contributor

vincent-paing commented Mar 6, 2022

For this issue, I have

  • expose platform API canScheduleExactAlarms
  • expose Intent ACTION_REQUEST_SCHEDULE_EXACT_ALARM to send users to settings screen and

Working on the last one now, will submit a PR after I've finished

  • ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED receiver to reschedule alarms

@bytehala
Copy link

bytehala commented May 25, 2022

Should this issue be Closed now?

@helenaford
Copy link
Member

@bytehala yes. will close. thanks 🙏

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

No branches or pull requests

4 participants