Skip to content

onNotificationOpenedApp is not working on Android #3695

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

Closed
15110011 opened this issue May 27, 2020 · 14 comments
Closed

onNotificationOpenedApp is not working on Android #3695

15110011 opened this issue May 27, 2020 · 14 comments

Comments

@15110011
Copy link

Everything works well on the IOS device but Android not, on Android device it still receives notification but when pressing the noti, then the app opens itself but onNotificationOpenedApp function is not run.
Package in used:

    "@react-native-firebase/app": "^7.1.0",
    "@react-native-firebase/messaging": "^7.1.0",
    "react-native-push-notification": "^3.5.1",
    "@react-native-community/push-notification-ios": "^1.2.0",
@Newbornbird
Copy link

Newbornbird commented May 28, 2020

Hello, I had the same problem.
My problem was in SplashActivity file.
Do you use it?

@roni-castro
Copy link

roni-castro commented May 28, 2020

I also had this problem and it was caused by the lib react-native-splash-screen as mentioned on this thread, because it receives the push Intent on Android, but do not pass it to the MainActivity.
If I understood right, this callback is just called when the app is on background state, not on foreground or in quit state, so to handle the notification on the quit state you will have to use the getInitialNotification, but for the foreground state I don't think there's a way to identify that the notification was tapped as someone also reported this problem

@15110011
Copy link
Author

15110011 commented May 29, 2020

@Newbornbird Thanks, I solved this, so now I get a new problem that every time I push a new notification from firebase console the onNotificationOpenedApp function run automatically one time with no data. When I press the notification on the notification panel of the device it will run onNotificationOpenedApp function again with data. So how can I force first running this function when receiving notification from the firebase console?

@ghasemikasra39
Copy link

same here:

    "@react-native-firebase/analytics": "^7.1.0",
    "@react-native-firebase/app": "^7.1.0",
    "@react-native-firebase/auth": "^8.0.0",
    "@react-native-firebase/crashlytics": "^7.1.0",
    "@react-native-firebase/firestore": "^7.1.0",
    "@react-native-firebase/messaging": "^7.1.1",

Any solution?

@ghasemikasra39
Copy link

Dear @roni-castro
I am using react-native-splash-screen and facing this issue.
Can you confirm that by removing this package this issue will be solved?

@mikehardy
Copy link
Collaborator

@ghasemikasra39 crazycodeboy/react-native-splash-screen#289 (comment)

@russellwheatley
Copy link
Member

Feel free to continue the discussion, but this is not an issue/bug with React Native Firebase.

@ZaikinaEvgeniya-2
Copy link

"@react-native-firebase/app": "^8.4.6",
"@react-native-firebase/messaging": "^7.9.1",
"react-native-push-notification": "^6.1.1",
"@react-native-community/push-notification-ios": "^1.6.1",

I see notification from Cloud Message in background, but onNotificationOpenedApp onMessage functions are not run in foreground

@mikehardy
Copy link
Collaborator

@ZaikinaEvgeniya-2 no comments here will receive attention. It's a closed issue nearly half a year, new issue with full template

@anupamhore
Copy link

Feel free to continue the discussion, but this is not an issue/bug with React Native Firebase.

How are you so sure.. when many of us are facing this issues....

@mikehardy
Copy link
Collaborator

Because I personally use it. I have watched my apps logs on device and seen it work. That leads me to believe it is working

@datachanturia
Copy link

datachanturia commented Jun 2, 2022

@mikehardy thanks react-native-splash-screen uninstall helped 👀

Actually in my case adding intent.putExtras(getIntent().getExtras()); in android/app/src/main/java/com/myapp/SplashActivity.java helped;

Full content of that file:

package com.myapp;

import android.content.Intent;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(this, MainActivity.class);
        intent.putExtras(getIntent().getExtras());  // Pass along FCM messages/notifications etc.
        startActivity(intent);
        finish();
    }
}

@Felipitoo
Copy link

@datachanturia did u do smth after changing the SplashActivity.java? because i already did that and i havent been able to make it work sadly :(

@datachanturia
Copy link

@datachanturia did u do smth after changing the SplashActivity.java? because i already did that and i havent been able to make it work sadly :(

@Felipitoo I don't think I did something else here.. just remember it didn't work until I clear the cache and build project again..

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

11 participants