Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit b61ce08

Browse files
authored
Merge pull request #807 from Truebill/fix-pop-initial
Fix pop initial for firebase
2 parents a071458 + 1510612 commit b61ce08

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,18 @@ public Map<String, Object> getConstants() {
6161
return constants;
6262
}
6363

64-
public void onNewIntent(Intent intent) {
64+
private Bundle getBundleFromIntent(Intent intent) {
65+
Bundle bundle = null;
6566
if (intent.hasExtra("notification")) {
66-
Bundle bundle = intent.getBundleExtra("notification");
67+
bundle = intent.getBundleExtra("notification");
68+
} else if (intent.hasExtra("google.message_id")) {
69+
bundle = intent.getExtras();
70+
}
71+
return bundle;
72+
}
73+
public void onNewIntent(Intent intent) {
74+
Bundle bundle = this.getBundleFromIntent(intent);
75+
if (bundle != null) {
6776
bundle.putBoolean("foreground", false);
6877
intent.putExtra("notification", bundle);
6978
mJsDelivery.notifyNotification(bundle);
@@ -155,8 +164,7 @@ public void getInitialNotification(Promise promise) {
155164
WritableMap params = Arguments.createMap();
156165
Activity activity = getCurrentActivity();
157166
if (activity != null) {
158-
Intent intent = activity.getIntent();
159-
Bundle bundle = intent.getBundleExtra("notification");
167+
Bundle bundle = this.getBundleFromIntent(activity.getIntent());
160168
if (bundle != null) {
161169
bundle.putBoolean("foreground", false);
162170
String bundleString = mJsDelivery.convertJSON(bundle);
@@ -210,12 +218,12 @@ public void cancelLocalNotifications(ReadableMap userInfo) {
210218
}
211219

212220
@ReactMethod
213-
/**
214-
* Clear notification from the notification centre.
215-
*/
216-
public void clearLocalNotification(int notificationID) {
217-
mRNPushNotificationHelper.clearNotification(notificationID);
218-
}
221+
/**
222+
* Clear notification from the notification centre.
223+
*/
224+
public void clearLocalNotification(int notificationID) {
225+
mRNPushNotificationHelper.clearNotification(notificationID);
226+
}
219227

220228
@ReactMethod
221229
public void registerNotificationActions(ReadableArray actions) {

0 commit comments

Comments
 (0)