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
Android: onForegroundEvent not listening to onPress Event #621
Comments
@helenaford As requested by you, created this issue |
Thanks for posting this. What I did:
What I get:
What I dont get:
Opening the app if not in foreground works, I just dont get notified about the event.
expo config
|
Hey @qroac, while this is getting fixed, I've just done a temporary workaround. Assuming that, you are using redux-toolkit and react navigation. Here are the steps, that I took..
Here are the code snippets
|
I'm also facing the same problem, onForegroundEvent not getting fired when pressing on the notification on Android |
Me too. Having same problem. Can't receive foreground event
|
can you post a step-by-step of how to recreate this bug? it's not clear to me as you mention both the background and foreground event handlers. This is the payload from our test app:
|
ohhh, isn't this the same issue #529? I think I understand now what you are saying the problem is... that you're receiving a background event but you think it should be a foreground event instead 🤔 |
This is a huge problem for us. It seems to me that there is not a thorough testing process for releases. I have the following testing process for both iOS and Android which would be good to mirror at some level. I get the desire for automated testing, but every release I run into an issue with FCM + Notifee.
|
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
Thank you for your contributions. |
if you use |
The issue is still present in 7.4.0 |
Still having this issue in 7.5.0 I could make a workaround using redux and redux persist, following the example posted by quicksilverr. Thanks |
still having this issue, i can listen DELIVERED event, but when i press the notification it does nothing |
Having the same problem, only receive delivered events onForegroundEvent but no press events. |
I also checked that it was not working. Event 1 is not displayed after clicking Alert. on Android |
Same issue here! Android 12. Only "delivered" event works. Issue still present in 7.6.1 |
does anyone know when this stopped working? I'm looking into this now, can see the issue you describe. definitely hasn't always been like this. i wonder if it's todo with android 12 +. |
It's been an issue for at least the last 5 months. Didn't seem to be an issue in October last year but by December I've been fighting it. |
In my case, there was a problem with Android 12 version. |
Hey All, I've pushed a solution and a pre-release of v7.7.0-0.
I've left some notes on the p/r with a screen recording showing the final result. #720 I will not actually publish this as a final version until Monday which gives time for feedback. Reopened issue for now until it's in a final release. |
Hey @helenaford I am currently facing with triggering the onPress event of notification click when a notification is received in the background. As when a notification is received in the foreground, the onPress event is triggered without any issues. However, when the notification is received in the background, the onPress event is not triggered (notifee.onBackgroundEvent). I have added my index.js class code
|
me too. @Sandeep145XamRN
I tested it with v7.7.0-0. The devices tested are Galaxy s20 and Android 12 versions. @helenaford Thank you for your efforts to solve this problem. |
I'm facing the same issue @Sandeep145XamRN @k0502s have you found any solution? "react-native": "0.70.6", "@notifee/react-native": "7.7.0-0"@helenaford thanks for a great library. I understand that you are dealing with a lot of issues, but I wanted to bring your attention to a particular issue, which is crucial, I'm unable to work on notification re-direction. Any guidance will be appreciated. |
@k0502s @MandeepKaur-1 please can you provide a screen recording? Sometimes it may be still classed as "foreground" if the app is running but may visually be in the background. If you have just pushed it into the background without opening another app for example. Have you checked out my video on the p/r #720. This shows when the background event is fired What is the re-direction issue you are facing? Are you receiving a foreground event instead? |
I tested this with the example app we have If it is not crashing your app when it's firing the foreground event when the app is active (even if visually it's in the background), then I think that is fine. If you need to know if the app is in focus for a specific foreground event, you can use the I really don't like that it's called And, then the But this latest fix is to get the same original behaviour where background event can mean quit or in the background, and foreground event is when the app is in focus on the screen. As I mentioned above, if you could provide a video or more details of how this negatively effects your app, that would be helpful. |
@helenaford You always work hard. Thank you. What I learned from watching this video(#720) is that you get a push notification from the foreground of the video, then switch to the background and click on the push notification. The flow I tested had a problem when I switched to the background before receiving a push notification and then got a push notification in the background state and then clicked on the push notification. I'm sorry, but I can't upload the video right now. I'll try v7.7.0-0 as soon as I have time. Thank you. |
Hi @helenaford Thank you so much for your guidance!!, I'm attaching a detailed screen recording of whole notification flow testing, In my case background event not working in any of case even app is in kill state. Please check attached video. Untitled.2.mp4Environment
let me know in case you require further information regarding same. |
Same here when I get push notifications in background like this video and click push notifications, there is no response. |
@Sandeep145XamRN have you found any solution? I am facing same issue in background notification. |
same issue for me, I use |
@Sandeep145XamRN that's expected for remote notifications. You need to use the RNFB messaging background handler because your notification has a title and body. @k0502s , I believe this could the same issue are you describe above too |
@samjuyal @edritech93 please can you specify which issue you are experiencing? There's alot of various sub issues in this thread, so the more specific you can be, the better |
Hey @helenaford Thank you for your attention to this matter!! Yeah, I have also used the same approach. However, the Firebase handler is not working with the latest version https://www.npmjs.com/package/@notifee/react-native/v/7.7.0-0: on iOS platform. To resolve this issue, I had to downgrade the version of Notifee to https://www.npmjs.com/package/@notifee/react-native/v/5.7.0. But there are some issues with this version too, as the notification permission popup does not appear on the Android platform. I think downgrading the version is not a good solution, whereas the latest versions should have Firebase events listening capabilities for iOS too(working seamlessly on Android). If we do that, we will not be able to use the latest features of the library. I am adding some code snippets, hoping that it will be helpful for push notification handling. If you are using a native splash screen for android, then its code should be as given below. ignore if you are using SplashActivity.java
App.js
|
Same issue for me, on expo SDK 48, notifee ^7.6.1 and react native 0.71.6 |
for iOS, please use the notifee methods. |
Closing issue as original issue is now fixed with pre-release |
The onBackgroundEvent method is not functioning in the background state even though v7.7.0-0 is using the setBackgroundMessageHandler. |
@k0502s please can you be more detailed? which platform and which type of notification? local (via notifee) or remote (via RNFB)? |
You always work hard. Thank you! |
The issue is still present in 7.8.2 on Android @react-native-firebase/messaging 19.2.2 Test case:
|
Any update on this? |
When using remote notifications on React Native, I've had the most luck with these docs. It directly states that onForegroundEvent will fire when it's a remote notification. I'm able to send notifications via the Firebase Messaging Console. The way I've handled it is to place the notifee.onForegroundEvent subscriber onto my home screen and then handle any navigation logic from there. That way I have access to a navigation object and can navigate or pass params. Surprisingly, this onForegroundEvent code even runs from the kill state. I am only able to get onBackgroundEvent to fire from local notifications while the app is running, not remote notifications Using // One Time USE EFFECT function to set things up!!
useEffect(() => {
const unsubscribeNotifee = notifee.onForegroundEvent(
async ({ type, detail }) => {
console.log(
`The type is`,
type,
"the detail is",
detail
);
switch (type) {
case EventType.PRESS:
if (detail.notification?.remote) {
console.log("It was a remote notification")
// Do some navigation logic
}
break;
case EventType.ACTION_PRESS:
console.log(`It was an ACTION PRESS THO`)
break;
}
}
);
return () => {
unsubscribeNotifee();
};
}, []); |
Hey, thanks for building such a cool package for handling notifications in RN.
The current issue that I'm facing is that, if the app is in the foreground state and I click on the notification. The onForegroundEvent is not listening to that action, and I'm unable to receive the notification payload or any event type, rather it gives the warning that the onBackgroundEvent is not setup.
The strange thing is that, when the notification is delivered. I'm able to get a log from the onForegroundEvent, for the Event type delivered, but on clicking the notification, nothing happens.
Info
The current workaround, that I'm using is, which was suggested by @mikehardy .
Being, we store the notification in the onBackgroundEvent, in a global state management storage and then retrieve it, wherever in the app we require.
The text was updated successfully, but these errors were encountered: