Hi, guys, I have a problem is when the app was killed, I can't get any notifications. How can I get localNotificationSchedule when the app get killed?? thank you.
And I tried use react native background jobhttps://www.npmjs.com/package/react-native-background-job to run localNotificationSchedule, but still not work
That should work out of the box without using other packages. Make sure that the notifications are scheduled. On which OS are you observing this problem?
thank you for reply, varugnpta85, on IOS, it works, but on android, when I killed the app, than I can't receive any notification.
What should I do..
Share your code for Android to schedule the local notifications.
var idString = id.toString();
//var date1 = new Date(this.state.date)
//this.getDate(this.state.date);
PushNotification.localNotificationSchedule({
userInteraction: true,
foreground: false,
message: this.state.text,
date: this.state.date,
userInfo: {
id: idString
},
//id: idString,
repeatType: repeatSelection[selected-1],
});
Can you confirm that the this.state.date is an instance of Date object and not the epoch time in milliseconds? Also userInteraction and foreground are not required.
I am also assuming that the scheduled notification shows up correctly if you don't close the app.
Thank you for reply, varugnpta85, I am sure that the date is an instance of Date object. And the scheduled notification shows up correctly when the app was not killed.
I find I got a error on android
RNPushNotification failed to process intent Intent { cmp=com.rerereminder/com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService (has extras) }
maybe this error make me can't show up the notification when the app was killed?
@zerophilip did you solve your problem? I also can't manage to make localNotificationSchedule work after I close (kill) my app. It works in foreground and background fine, but when I kill app I don't receive local notifications anymore on Android.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.
@zerophilip @krzysztofjablonski Has this been solved? I am still facing this issue in latest version? Are there any alternative for this?
@krzysztofjablonski @zerophilip @nabinkumarn
any luck solving this one? Or possibly a workaround?
@bernhardt1 this is due to mobile OS battery optimization. Once you disable battery optimization, it works fine. You need to prompt user to disable battery optimization for your app. That is the only workaround I found. here
Most helpful comment
@zerophilip @krzysztofjablonski Has this been solved? I am still facing this issue in latest version? Are there any alternative for this?