After changing DailyNotificationReceiver to exported="true", testing revealed
that while the receiver works when manually triggered, AlarmManager broadcasts
are not reaching it when alarms fire automatically. Alarms are scheduled and
fire correctly, but the PendingIntent broadcast does not trigger the receiver.
Added comprehensive documentation and diagnostic tools:
1. Documentation (doc/daily-notification-plugin-android-receiver-issue.md):
- Complete problem analysis with evidence from logs and dumpsys
- Root cause hypotheses focusing on PendingIntent creation in plugin
- Testing steps and expected behavior after fix
- Technical details for plugin maintainer reference
2. Test scripts:
- scripts/test-notification-receiver.sh: Manually trigger receiver to
verify it works and test with/without ID parameter
- scripts/check-alarm-logs.sh: Check logs and verify alarm scheduling
Findings:
- Receiver registration is correct (exported="true" works for manual tests)
- Alarms schedule and fire successfully (confirmed via dumpsys alarm)
- Issue is in plugin's PendingIntent creation - broadcasts don't reach receiver
- Additional issue: Intent extras missing scheduleId (causes "missing_id" error)
The exported="true" change was necessary and correct. The remaining issue
requires a fix in the plugin's PendingIntent creation code to explicitly
set the component and include the scheduleId in Intent extras.
This documentation is intended for use when working on the plugin project
to fix the PendingIntent delivery issue.
7.6 KiB
Daily Notification Plugin - Android Receiver Not Triggered by AlarmManager
Date: 2026-02-02
Status: 🔴 Critical Bug - Alarms Fire But Receiver Not Triggered
Plugin: @timesafari/daily-notification-plugin
Platform: Android
Issue: AlarmManager fires alarms but DailyNotificationReceiver is not receiving broadcasts
Problem Summary
Alarms are being scheduled successfully and fire at the correct time, but the DailyNotificationReceiver is not being triggered when AlarmManager delivers the broadcast. Manual broadcasts to the receiver work correctly, indicating the receiver itself is functional.
What Works ✅
- Receiver Registration: The receiver is properly registered in AndroidManifest.xml with
exported="true" - Manual Broadcasts: Manually triggering the receiver via
adb shell am broadcastsuccessfully triggers it - Alarm Scheduling: Alarms are successfully scheduled via
setAlarmClock()and appear indumpsys alarm - Alarm Firing: Alarms fire at the scheduled time (confirmed by alarm disappearing from dumpsys)
What Doesn't Work ❌
- Automatic Receiver Triggering: When AlarmManager fires the alarm, the broadcast PendingIntent does not reach the receiver
- No Logs on Alarm Fire: No
DN|RECEIVE_STARTlogs appear when alarms fire automatically - Missing ID in Intent: When manually tested, receiver shows
DN|RECEIVE_ERR missing_id(separate issue but related)
Technical Details
Receiver Configuration
File: android/app/src/main/AndroidManifest.xml
<receiver
android:name="com.timesafari.dailynotification.DailyNotificationReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.timesafari.daily.NOTIFICATION" />
</intent-filter>
</receiver>
- ✅
exported="true"is set (required for AlarmManager broadcasts) - ✅ Intent action matches:
com.timesafari.daily.NOTIFICATION - ✅ Receiver is inside
<application>tag
Alarm Scheduling Evidence
From logs when scheduling (23:51:32):
I DNP-SCHEDULE: Scheduling OS alarm: variant=ALARM_CLOCK, action=com.timesafari.daily.NOTIFICATION, triggerTime=1770105300000, requestCode=44490, scheduleId=timesafari_daily_reminder
I DNP-NOTIFY: Alarm clock scheduled (setAlarmClock): triggerAt=1770105300000, requestCode=44490
From dumpsys alarm output:
RTC_WAKEUP #36: Alarm{7a8fb5e type 0 origWhen 1770148800000 whenElapsed 122488536 app.timesafari.app}
tag=*walarm*:com.timesafari.daily.NOTIFICATION
type=RTC_WAKEUP origWhen=2026-02-03 12:00:00.000 window=0 exactAllowReason=policy_permission
operation=PendingIntent{6fce955: PendingIntentRecord{5856f6a app.timesafari.app broadcastIntent}}
Alarm Firing Evidence
- Alarm scheduled for 23:55:00 (timestamp: 1770105300000)
- At 23:55:00, alarm is no longer in
dumpsys alarm(confirmed it fired) - No
DN|RECEIVE_STARTlog at 23:55:00 (receiver was not triggered)
Manual Broadcast Test (Works)
adb shell am broadcast -a com.timesafari.daily.NOTIFICATION -n app.timesafari.app/com.timesafari.dailynotification.DailyNotificationReceiver
Result: ✅ Receiver triggered successfully
02-02 23:46:07.505 DailyNotificationReceiver D DN|RECEIVE_START action=com.timesafari.daily.NOTIFICATION
02-02 23:46:07.506 DailyNotificationReceiver W DN|RECEIVE_ERR missing_id
Root Cause Analysis
The issue appears to be in how the PendingIntent is created when scheduling alarms. Possible causes:
Hypothesis 1: PendingIntent Not Targeting Receiver Correctly
The PendingIntent may be created without explicitly specifying the component, causing Android to not match it to the receiver when the alarm fires.
Expected Fix: When creating the PendingIntent for AlarmManager, explicitly set the component:
val intent = Intent("com.timesafari.daily.NOTIFICATION").apply {
setComponent(ComponentName(context, DailyNotificationReceiver::class.java))
putExtra("id", scheduleId) // Also fix missing_id issue
}
val pendingIntent = PendingIntent.getBroadcast(
context,
requestCode,
intent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
Hypothesis 2: PendingIntent Flags Issue
The PendingIntent may be created with incorrect flags that prevent delivery when the app is in certain states.
Check: Ensure flags include:
FLAG_UPDATE_CURRENTorFLAG_CANCEL_CURRENTFLAG_IMMUTABLE(required on Android 12+)
Hypothesis 3: Package/Component Mismatch
The PendingIntent may be created with a different package name or component than what's registered in the manifest.
Check: Verify the package name in the Intent matches app.timesafari.app and the component matches the receiver class.
Additional Issue: Missing ID in Intent
When the receiver IS triggered (manually), it shows:
DN|RECEIVE_ERR missing_id
This indicates the Intent extras don't include the scheduleId. The plugin should add the ID to the Intent when creating the PendingIntent:
intent.putExtra("id", scheduleId)
// or
intent.putExtra("scheduleId", scheduleId) // if receiver expects different key
Testing Steps for Plugin Fix
-
Verify PendingIntent Creation:
- Check the code that creates PendingIntent for AlarmManager
- Ensure component is explicitly set
- Ensure ID is added to Intent extras
-
Test Alarm Delivery:
- Schedule an alarm for 1-2 minutes in the future
- Monitor logs:
adb logcat | grep -E "DN|RECEIVE_START|DailyNotification" - Verify
DN|RECEIVE_STARTappears when alarm fires - Verify no
missing_iderror
-
Test Different App States:
- App in foreground
- App in background
- App force-closed
- Device in doze mode (if possible on emulator)
-
Compare with Manual Broadcast:
- Manual broadcast works → receiver is fine
- Alarm broadcast doesn't work → PendingIntent creation is the issue
Files to Check in Plugin
- Alarm Scheduling Code: Where
setAlarmClock()orsetExact()is called - PendingIntent Creation: Where
PendingIntent.getBroadcast()is called - Intent Creation: Where the Intent for the alarm is created
- Receiver Code: Verify what Intent extras it expects (for missing_id fix)
Related Configuration
AndroidManifest.xml (App Side)
- ✅ Receiver exported="true"
- ✅ Correct intent action
- ✅ Receiver inside application tag
Permissions (App Side)
- ✅ POST_NOTIFICATIONS
- ✅ SCHEDULE_EXACT_ALARM
- ✅ USE_EXACT_ALARM
- ✅ RECEIVE_BOOT_COMPLETED
- ✅ WAKE_LOCK
Expected Behavior After Fix
When an alarm fires:
- AlarmManager delivers the broadcast
DailyNotificationReceiver.onReceive()is called- Log shows:
DN|RECEIVE_START action=com.timesafari.daily.NOTIFICATION - Receiver finds the ID in Intent extras (no
missing_iderror) - Notification is displayed
Notes
- The
exported="true"change in the app's manifest was necessary and correct - The issue is in the plugin's PendingIntent creation, not the app configuration
- Manual broadcasts work, proving the receiver registration is correct
- Alarms fire, proving AlarmManager scheduling is correct
- The gap is in the PendingIntent → Receiver delivery
Quick Reference: Working Manual Test
# This works - receiver is triggered
adb shell am broadcast \
-a com.timesafari.daily.NOTIFICATION \
-n app.timesafari.app/com.timesafari.dailynotification.DailyNotificationReceiver \
--es "id" "timesafari_daily_reminder"
The plugin's PendingIntent should create an equivalent broadcast that AlarmManager can deliver.