Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3486738
D6366.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6366.diff
View Options
diff --git a/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
--- a/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
+++ b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
@@ -5,10 +5,13 @@
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import com.facebook.react.bridge.NativeModule;
+import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
+import com.facebook.react.bridge.WritableMap;
+import com.google.firebase.messaging.RemoteMessage;
public class CommAndroidNotifications extends ReactContextBaseJavaModule {
private NotificationManager notificationManager;
@@ -46,4 +49,18 @@
}
}
}
+
+ @ReactMethod
+ public void getInitialNotification(Promise promise) {
+ RemoteMessage initialNotification =
+ getCurrentActivity().getIntent().getParcelableExtra("message");
+ if (initialNotification == null) {
+ promise.resolve(null);
+ return;
+ }
+ WritableMap jsReadableNotification =
+ CommAndroidNotificationParser.parseRemoteMessageToJSForegroundMessage(
+ initialNotification);
+ promise.resolve(jsReadableNotification);
+ }
}
diff --git a/native/push/android.js b/native/push/android.js
--- a/native/push/android.js
+++ b/native/push/android.js
@@ -6,6 +6,7 @@
type CommAndroidNotificationsModuleType = {
+removeAllActiveNotificationsForThread: (threadID: string) => void,
+ +getInitialNotification: () => Promise<?AndroidForegroundMessage>,
...
};
export type AndroidForegroundMessage = {
diff --git a/native/push/push-handler.react.js b/native/push/push-handler.react.js
--- a/native/push/push-handler.react.js
+++ b/native/push/push-handler.react.js
@@ -349,9 +349,7 @@
return;
}
this.initialAndroidNotifHandled = true;
- const initialNotif = await getFirebase()
- .notifications()
- .getInitialNotification();
+ const initialNotif = await CommAndroidNotifications.getInitialNotification();
if (initialNotif) {
await this.androidNotificationOpened(initialNotif);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 5:51 AM (20 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675557
Default Alt Text
D6366.diff (2 KB)
Attached To
Mode
D6366: Implement native method to get initial notification and use it in JavaScript
Attached
Detach File
Event Timeline
Log In to Comment