-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
onNotification is not getting called when opening the notification from background in Android #1592
Comments
Hi @vineelk8 |
This is happening with me too, @Dallas62, on Android, it only fires |
@Dallas62 My team is experiencing a similar issue of |
Hi @Dallas62 @PauloMello99 @TheNoodleMoose The issue resolved for me, I'm using react-native-splash-screen so when I press notification from the background, the onNotification method is not triggered. So I fixed it on changing code in MainActivity.java and SplashScreen.Java |
@vineelk8 What do you mean when you say 'changing code in MainActivity.java and SplashScreen.Java'? I recently implemented this lib and just faced this now |
Did you use react-native-splash-screen npm package? |
@vineelk8 Yep |
Add this inside MainActivity.java
This is SplashActivity.java |
@vineelk8 It makes sense, you cannot get the initial extras if there's another activity being opened at first, thank you so much!! |
@PauloMello99 Is your issue solved? |
Hell yeah! |
@PauloMello99 @vineelk8 thanks for the proposed solution. Looks like i'm getting the same issue. I don't see any |
Please take a look in the react-native-splash-screen documentation, one of the steps to introduce the SplashScreenActivity is in the Android part |
@PauloMello99 will do thanks. Someone else set it up at the project i'm working on, so I haven't seen that yet. Thanks 🙌 |
For anyone else struggling with this, the code snippet in |
@TheNoodleMoose I'm was facing the same scenario, after some debugging I discover that we need to put PushNotification.popInitialNotification inside the App component in a useEffect/componentDidMount because when you press the back button and then open the app again react native doesn't restart all js code just the components, so putting popInitialNotification (prop or function) in a js outside the component scope will not run again when app start in this scenario. But do not put .configure inside a component! just the PushNotification.popInitialNotification and pass popInitialNotification: false in configure. I also made the above native code because I also have a SplashActivity. |
so many thanks for this solution, this solve my problem. it almost takes me a whole day on struggling all kinds of try and try.... |
Hi bro, Can you publish the MainActivity code and SplashActivity I put de onNewIntent method in a MainActivity, but I don't see that the method called. I feel that it's my problem. My code MainActivity.java public class MainActivity extends ReactActivity { @OverRide
@OverRide }` My SplashActivity `... public class SplashActivity extends AppCompatActivity {
}` |
This worked for me as well. For me the |
@vineelk8 if I was using splash screen and with your solution, my notification() is working, but can you please explain why it was not working without the changes? |
Hi, |
Can you please add this common SplashActivity error to the README in a kind of "Common errors" section? It seems like it happened to a lot of people and it would stop people from creating the same issue over and over again |
Hi @nachoperez714 |
I'm also having the same problem |
Use notifee instead of react native push notification, this library is not being maintained for a long time now. I have tested notifee for the task and it worked like a charm. |
onNotification is not getting called when opening the notification from a background in Android -- Remote Notifications with firebase.
Below are the files modified
build.gradle
settings.gradle
app/build.gradle
AndroidManifest.xml
package.json
pushNotificationService.js
App.js
Please, someone, help me out in this issue
The text was updated successfully, but these errors were encountered: