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

Scheduled local notifications are not showing up after reboot on Android #991

Closed
MrAdex77 opened this issue Feb 14, 2024 · 3 comments
Closed

Comments

@MrAdex77
Copy link

MrAdex77 commented Feb 14, 2024

Hello, I'm testing on an Android emulator with battery optimizations turned off, Android 14. And the trigger notifications with alarmManager or the other one are not showing up after reboot. It doesn't works also on Samsung, one-plus and Xiaomi
Example code:

      const trigger: TimestampTrigger = {
        type: TriggerType.TIMESTAMP,
        alarmManager: { type: AlarmType.SET_EXACT_AND_ALLOW_WHILE_IDLE },
        timestamp,
      };
      const notifeeNotification: NotifeeNotification = {
        title,
        body,
        data: { },
        android: {
          channelId: androidChannelId,
          pressAction: androidPressAction,
          importance: AndroidImportance.HIGH,
        },
      };
      const notificationId = await notifee.createTriggerNotification(notifeeNotification, trigger);

Repro steps:

  • Create trigger notification which should show up in 5 min
  • Reboot phone
  • don't open the app, wait for the exact time, there is no notification.

From logs I can see only the following:

02-14 15:11:31.267 6330 6330 D NOTIFEE : (context): received application context
02-14 15:12:03.032 6330 6330 D NOTIFEE : (NotifeeAlarmManager): Reschedule Notifications on reboot

@MrAdex77
Copy link
Author

It seems that the issue was resolved by adding this permission to AndroidManifest:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />,

@helenaford I couldn't find any information that it is needed to do it manually in the documentation, maybe I just missed it but if not could you add it for others? It wasn't working on Android 13/14 and I thought the package its injecting these permissions by itself.

@mikehardy
Copy link
Contributor

Very strange. The library has two parts, a thing react-native-specific wrapper and a core library that is also possible to use in Flutter.

Both of those have an AndroidManifest.xml file and the core library has this permission:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

If you open your app in AndroidStudio I believe it is possible to look at a "Merged Manifest" view and see what permissions are in there.

If you do that, without the line you added explicitly using permission RECEIVE_BOOT_COMPLETED at the app level, do you see that permission still merging in from the core library? You should. It is supposed to work that way...

@MrAdex77
Copy link
Author

MrAdex77 commented Feb 16, 2024

Hi,
thank you for your response,
I checked the merged manifest and it seems like this permission is there, but when I build the release version of the APK, the permissions on Google Play that are there are only:

android.permission.ACCESS_ADSERVICES_AD_ID,
android.permission.ACCESS_ADSERVICES_ATTRIBUTION,
android.permission.ACCESS_ADSERVICES_TOPICS,
android.permission.ACCESS_NETWORK_STATE,
android.permission.ACCESS_NOTIFICATION_POLICY,
android.permission.ACCESS_WIFI_STATE,
android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS,
android.permission.FOREGROUND_SERVICE,
android.permission.INTERNET,
android.permission.POST_NOTIFICATIONS,
android.permission.READ_CALENDAR,
android.permission.SCHEDULE_EXACT_ALARM,
android.permission.USE_FULL_SCREEN_INTENT,
android.permission.VIBRATE, android.permission.WAKE_LOCK,
android.permission.WRITE_CALENDAR,
com.google.android.c2dm.permission.RECEIVE, com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE, com.google.android.gms.permission.AD_ID,
com.my.app.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION

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

No branches or pull requests

2 participants