Skip to content

android: notification in foreground triggers an empty notification in the notification tray and no notification if started from background #492

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
ruben4mobile opened this issue Feb 12, 2020 · 3 comments

Comments

@ruben4mobile
Copy link

I am using the latest version of this lib 3.1.1-snapshot.95.
because version 3.1.1 has an issue with the @nullable annotation in one of the files.

My react native version is 0.59.10.

When receiving a push message when the app is in the foreground the PushNotification.java file is also creating an empty notification in the tray. I don't want this, because I handle the notification in code.
On top of that I can't get the notification if the app is started from clicking on a notification when the app is killed/not started.

Can't we remove line 66 of the file PushNotification.java

public void onReceived() throws InvalidNotificationException {
        postNotification(null); -> delete this line
        notifyReceivedToJS();
    }

Or is there a possibility to dismiss the notification direct?

Regarding not receiving the notification from a cold start I suggest using the implementation from parseIntentForRemoteNotification in react-native-firebase 5.x

I created a native component that uses this so i can do run this code in my appliction

 /*
     * Check if app was opend by a clicking on a push notification. and the app was closed
     * No intrested in faillure so no catch
     * */
    if (IS_IOS) {
      void Notifications.getInitialNotification().then(notificationData => {
        if (notificationData && notificationData.payload && notificationData.payload.data) {
          this.handleNotification(notificationData.payload.data)()
        }
      })
    } else if (IS_ANDROID) {
      if (NativeModules.GetPushData && NativeModules.GetPushData.getInitialNotification) {
        void NativeModules.GetPushData.getInitialNotification().then((notification: any) => {
          if (notification && notification.notification && notification.notification.data) {
            this.handleNotification(notification.notification.data)()
          }
        })
      }
    }```

I am using react-native-firebase 6 because of crashlytics and the notification lib won't be available. Else I would keep on using react-native-firebase 5.x

Is there a way to fix these issues or am I using the lib wrong?
@patrickyin
Copy link
Contributor

The issue fix PR here: #496

@stale
Copy link

stale bot commented Mar 14, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the 🏚 stale label Mar 14, 2020
@stale
Copy link

stale bot commented Mar 21, 2020

The issue has been closed for inactivity.

@stale stale bot closed this as completed Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants