-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
onNotification not being called when app was killed on iOS #1501
Comments
onNotification
not being called when app was killed on iOS
Hi, |
Okay I will recreate the issue there! |
I just saw your issue with AppDelegate, the Apple documentation say that: application didReceiveLocalNotification:(UILocalNotification *)notification Is deprecated, and there is other issues on ios repo, to repace with something like « willPresentNotification ». |
It works fine for me in the background. Just not when the app is killed. |
In the new Notification SDK of Apple, local notifications doesn’t trigger the application if the user doesn’t interact with the notification . |
Hi again, just to be sure, can you provide the content of Reading your case and the version you are using, there might be a side affect of an Android change. https://github.com/zo0r/react-native-push-notification/blob/dev/CHANGELOG.md
|
Sorry @Dallas62, I was very busy the whole week. PushNotification.configure({
onNotification: handleNotificationClick,
onAction: handleNotificationActionClick
});
function handleNotificationClick(notification) {
const id = Platform.OS === "ios" ? notification.data.id : notification.id;
RootNavigation.navigate("Question", {
showBackButton: false,
notificationId: id
});
}
function handleNotificationActionClick(notification) {
let vote;
if (notification.action === "Yes") {
vote = 1;
} else if (notification.action === "No") {
vote = 3;
} else {
showToast("Unknown action clicked. Please vote manually.");
PushNotification.invokeApp(notification);
return;
}
// Do some stuff while the app should not launch...
} For Android everything works fine (including the actions). iOS works fine if the app was in fore- or background. |
@Dallas62 any news? 😇 |
Hi @mathiasmoeller |
Thanks a lot! 🙏 |
@Dallas62 any news? 😇 😬 |
Hi @mathiasmoeller, I'm on it 😉 |
Hi @mathiasmoeller |
Hi again @mathiasmoeller File & Line: react-native-push-notification/index.js Line 121 in 271461e
|
@Dallas62 I will test your fix ASAP! I think I will have time on Thursday. I will let you know if it fixes it |
@Dallas62 I will try to test it today. I have some important Android fixes to do but I hope I will be able to do it in the afternoon. |
Hi @mathiasmoeller |
Sadly I still could not get it to work when the app is killed. |
|
Yes it does not return anything.
|
This is really strange, I think this is a problem with the AppDelegate or project configuration, but not sure. Take care, in both issue (this and ios one) you let an API key. |
I found something, maybe it's useful.
Does this maybe describe the situation a bit better? (I know its not the most simple one 😉 ) |
@Dallas62 I tried the new 5.0.1 release. Any ideas? Thank you so much already! |
Hi @mathiasmoeller
Yes, but it's to unify notification format, result is based on I don't know which accuracy you expect between geolocalisation and notification, but did you tried to schedule a notification ? |
@Dallas62 thanks for the clarification. 60s should not be an issue for my use case I think. I could try that! But I'd prefer to get |
@Dallas62 maybe I have made some mistakes while setting up |
Actually there is nothing for iOS on the repository (expect JS implementation). If you have a small reproducible example, I can try to look directly. |
I can try to set up an example. But I don't think I have time for that in the next days. Let's see. I made another interesting observation: App starts in background, a notification is shown (not clicked), I open the app manually, I click the notification now -> So the problem seems to be that when the app starts in background, the listeners do not get attached properly? I have logs that tell me that |
You can try to attach listener on iOS library:
If it's triggered; there is an issue on this library or the use of |
I tested it with the ios implementation. The behaviour is exactly the same. So I guess it is for sure not an issue of |
scheduling the notification sadly does not help :/ |
Okay I build a sample project. This issue is: there it works...... FML! I did everything exactly the same way as I did it in my project. I found another log in XCode:
This sounds like it is an issue. Problem is, that I call |
Hi @mathiasmoeller |
Had the same issue. only happened on simulator but works fine on real device. try to stop debugging or remove the app from simulator and re install it again. |
@stevenasi thanks for the suggestion! It's just hard to test without the simulator since my events are triggered by background events 😁 But I will give it a try for sure! |
@stevenasi oh wow for me it is even worse. On the real device not even while the app is in fore- or background the notification handler is called! ARGH! |
@mathiasmoeller did you try to uninstall the app from the device and re-install it again because that what was causing the problem in my case. |
was this ever resolved? having this issue when I send a silent notification, the app wakes up from a kill state but doesn't call onNotification. This works well in android |
Also having a similar issue. Nothin gets called anything from a killed state. |
I could confirm this bug, it seems to work in release build but not in debug. What strange is in release build the payload that is passed down doesn't include title and message only the action property. |
After 2 days i fined the answer. |
Hi Friends, i have found solution. Please check below methods. Add this code in below file.
................. create new file methods in same class.... -(void) callNotification: (NSDictionary*) userInfo { Modify below File from framework
Update above line on this methods. Now Check, you will data on onNotification method...... Hope this work for you.... |
@SazzadIp Your solution works and it's a good one also I tried without framework changes and it's working on that case also.
|
I faced the same problem and for me the solution was to turn off the debug mode on the real device and after that the onNotification method started working. |
How did you do that? |
It doesn't work on simulator and when you use debug mode. |
It doesn't work for me. |
Bug
I am sending local notifications using
react-native-background-fetch
. This works good. When the user clicks on a notification I redirect him to a certain screen. This always works in Android.For iOS it is working when the app is in foreground or background. When the app was killed and the user clicks on a notification, the app launches but the
onNotification
handler is not being called.I call
PushNotification.configure
fromindex.js
, so timing should not be the issue.I followed the fix here to get
onNotification
to work in foreground and background.Environment info
react-native info
output:Library version: the development branch of this repo for the latest Android notification action fixes
Steps To Reproduce
onNotification
handler inindex.js
onNotification
handler was called when the notification is clickedDescribe what you expected to happen:
onNotification
should be called when coming from Foreground/Background or when the app was killedThe text was updated successfully, but these errors were encountered: