5.6 KiB
Plugin feedback: Android exact alarm — stop opening Settings automatically
Date: 2026-03-09
Target repo: daily-notification-plugin
Consuming app: crowd-funder-for-time-pwa (TimeSafari)
Platform: Android
Summary
When the consuming app calls scheduleDailyNotification() after the user has granted POST_NOTIFICATIONS, the plugin checks whether exact alarms can be scheduled (Android 12+). If not, it opens the system Settings (exact-alarm or app-details screen) and rejects the call. This is intrusive: the app prefers to schedule without forcing the user into Settings, and to inform the user about exact alarms in its own UI (e.g. a note in the success message).
Requested change: Remove the automatic opening of Settings for exact alarm permission from scheduleDailyNotification(). Either:
- Option A (preferred): Do not open Settings and do not reject when exact alarm is not granted. Proceed with scheduling (using inexact alarms if necessary when exact is unavailable), and let the consuming app handle any UX (e.g. optional hint to enable exact alarms).
- Option B: Do not open Settings, but still reject with a clear error code/message when exact alarm is required and not granted, so the app can show its own message or deep-link to Settings if desired.
Where this lives in the plugin
File: android/src/main/java/com/timesafari/dailynotification/DailyNotificationPlugin.kt
Method: scheduleDailyNotification(call: PluginCall)
Lines: ~1057–1109 (exact line numbers may shift with edits)
Current behavior:
- At the start of
scheduleDailyNotification(), the plugin callscanScheduleExactAlarms(context). - If
false:- If Android S+ and
canRequestExactAlarmPermission(context)is true: it buildsSettings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM, callscontext.startActivity(intent), logs "Exact alarm permission required. Opened Settings for user to grant permission." (tagDNP-PLUGIN), and rejects withEXACT_ALARM_PERMISSION_REQUIRED. - Else: it opens app details (
Settings.ACTION_APPLICATION_DETAILS_SETTINGS), logs "Exact alarm permission denied. Directing user to app settings.", and rejects withPERMISSION_DENIED.
- If Android S+ and
- Only if exact alarms are allowed does the plugin continue to schedule.
So the exact alarms feature here is: gate scheduling on exact alarm permission and, when not granted, open Settings and reject.
Evidence from consumer app (logcat)
Filter: DNP-PLUGIN, DNP-SCHEDULE, DailyNotificationWorker, DailyNotificationReceiver.
Typical sequence when user enables daily notification:
DNP-PLUGIN: Created pending permission request: ... type=POST_NOTIFICATIONS- User grants notification permission.
DNP-PLUGIN: Resolving pending POST_NOTIFICATIONS request on resume: granted=true- App calls
scheduleDailyNotification(...). DNP-PLUGIN: Exact alarm permission required. Opened Settings for user to grant permission.
The consumer app does not call any plugin API to “request exact alarm” or “open exact alarm settings”; it only calls requestPermissions() (POST_NOTIFICATIONS) and then scheduleDailyNotification(). The plugin’s own guard in scheduleDailyNotification() is what opens Settings.
Consumer app context
- Permission flow: The app requests
POST_NOTIFICATIONSvia the plugin’srequestPermissions(), then callsscheduleDailyNotification(). It does not request exact alarm permission itself. - UX: The app already shows an optional note when exact alarm is not granted (e.g. “If notifications don’t appear, enable ‘Exact alarms’ in Android Settings → Apps → TimeSafari → App settings”). It does not want the plugin to open Settings automatically.
- Manifest: The app declares
SCHEDULE_EXACT_ALARMin its AndroidManifest; the issue is only the automatic redirect to Settings and the reject when exact alarm is not yet granted.
Suggested plugin changes
- In
scheduleDailyNotification(): Remove the block that opens Settings and rejects when!canScheduleExactAlarms(context)(the block ~1057–1109). Do not callstartActivityforACTION_REQUEST_SCHEDULE_EXACT_ALARMorACTION_APPLICATION_DETAILS_SETTINGSfrom this method. - Scheduling when exact alarm is not granted: Prefer Option A: continue and schedule even when exact alarms are not allowed (e.g. use inexact/alarm manager APIs that don’t require exact alarm, or document that timing may be approximate). If the plugin must reject when exact is required, use Option B: reject with a specific error code/message and no
startActivity. - Leave other APIs unchanged: Methods such as
openExactAlarmSettings()orrequestExactAlarmPermission()can remain for apps that explicitly want to send the user to Settings; the change is only to stop doing it automatically insidescheduleDailyNotification().
Relation to existing docs
- Plugin:
doc/daily-notification-plugin-android-receiver-issue.mdanddoc/daily-notification-plugin-checklist.mddescribe use ofSCHEDULE_EXACT_ALARM(notUSE_EXACT_ALARM). This feedback does not change that; it only asks to stop auto-opening Settings inscheduleDailyNotification(). - Consumer app:
doc/notification-permissions-and-rollovers.mddescribes the permission flow;doc/NOTIFICATION_TROUBLESHOOTING.mdmentions exact alarms for user guidance.
Use this document when implementing the change in the daily-notification-plugin repo (e.g. with Cursor). After changing the plugin, update the consuming app’s dependency (e.g. npm update @timesafari/daily-notification-plugin), then npx cap sync android and rebuild.