Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3362368
D7193.id24190.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D7193.id24190.diff
View Options
diff --git a/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationParser.java b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationParser.java
--- a/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationParser.java
+++ b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationParser.java
@@ -17,18 +17,18 @@
CommNotificationsHandler.PREFIX_KEY);
public static WritableMap
- parseRemoteMessageToJSForegroundMessage(RemoteMessage message) {
+ parseRemoteMessageToJSMessage(RemoteMessage message) {
if (message.getData() == null) {
return null;
}
- WritableMap jsForegroundMessage = Arguments.createMap();
+ WritableMap jsMessage = Arguments.createMap();
for (String key : OBLIGATORY_KEYS) {
String value = message.getData().get(key);
if (value == null) {
return null;
}
- jsForegroundMessage.putString(key, value);
+ jsMessage.putString(key, value);
}
for (String key : OPTIONAL_KEYS) {
@@ -36,9 +36,9 @@
if (value == null) {
continue;
}
- jsForegroundMessage.putString(key, value);
+ jsMessage.putString(key, value);
}
- return jsForegroundMessage;
+ return jsMessage;
}
}
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
@@ -65,7 +65,7 @@
return;
}
WritableMap jsReadableNotification =
- CommAndroidNotificationParser.parseRemoteMessageToJSForegroundMessage(
+ CommAndroidNotificationParser.parseRemoteMessageToJSMessage(
initialNotification);
promise.resolve(jsReadableNotification);
}
diff --git a/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsEventEmitter.java b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsEventEmitter.java
--- a/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsEventEmitter.java
+++ b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsEventEmitter.java
@@ -32,8 +32,8 @@
new CommAndroidNotificationsTokenReceiver(),
new IntentFilter(CommNotificationsHandler.TOKEN_EVENT));
localBroadcastManager.registerReceiver(
- new CommAndroidNotificationsForegroundMessageReceiver(),
- new IntentFilter(CommNotificationsHandler.FOREGROUND_MESSAGE_EVENT));
+ new CommAndroidNotificationsMessageReceiver(),
+ new IntentFilter(CommNotificationsHandler.MESSAGE_EVENT));
}
@Override
@@ -72,7 +72,7 @@
return;
}
WritableMap jsReadableNotification =
- CommAndroidNotificationParser.parseRemoteMessageToJSForegroundMessage(
+ CommAndroidNotificationParser.parseRemoteMessageToJSMessage(
initialNotification);
if (jsReadableNotification != null) {
sendEventToJS(
@@ -89,17 +89,15 @@
}
}
- private class CommAndroidNotificationsForegroundMessageReceiver
+ private class CommAndroidNotificationsMessageReceiver
extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
RemoteMessage message = intent.getParcelableExtra("message");
- WritableMap jsForegroundMessage =
- CommAndroidNotificationParser.parseRemoteMessageToJSForegroundMessage(
- message);
- if (jsForegroundMessage != null) {
- sendEventToJS(
- "commAndroidNotificationsForegroundMessage", jsForegroundMessage);
+ WritableMap jsMessage =
+ CommAndroidNotificationParser.parseRemoteMessageToJSMessage(message);
+ if (jsMessage != null) {
+ sendEventToJS("commAndroidNotificationsMessage", jsMessage);
}
}
}
diff --git a/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java b/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
--- a/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
+++ b/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
@@ -49,8 +49,7 @@
public static final String THREAD_ID_KEY = "threadID";
public static final String TOKEN_EVENT = "TOKEN_EVENT";
- public static final String FOREGROUND_MESSAGE_EVENT =
- "FOREGROUND_MESSAGE_EVENT";
+ public static final String MESSAGE_EVENT = "MESSAGE_EVENT";
@Override
public void onCreate() {
@@ -113,10 +112,11 @@
Log.w("COMM", "Database not existing yet. Skipping notification");
}
+ Intent intent = new Intent(MESSAGE_EVENT);
+ intent.putExtra("message", message);
+ localBroadcastManager.sendBroadcast(intent);
+
if (this.isAppInForeground()) {
- Intent intent = new Intent(FOREGROUND_MESSAGE_EVENT);
- intent.putExtra("message", message);
- localBroadcastManager.sendBroadcast(intent);
return;
}
this.displayNotification(message);
diff --git a/native/push/android.js b/native/push/android.js
--- a/native/push/android.js
+++ b/native/push/android.js
@@ -6,7 +6,7 @@
type CommAndroidNotificationsModuleType = {
+removeAllActiveNotificationsForThread: (threadID: string) => void,
- +getInitialNotification: () => Promise<?AndroidForegroundMessage>,
+ +getInitialNotification: () => Promise<?AndroidMessage>,
+createChannel: (
channelID: string,
name: string,
@@ -20,7 +20,7 @@
+getToken: () => Promise<string>,
+NOTIFICATIONS_IMPORTANCE_HIGH: string,
};
-export type AndroidForegroundMessage = {
+export type AndroidMessage = {
+body: string,
+title: string,
+threadID: string,
@@ -34,7 +34,7 @@
const androidNotificationChannelID = 'default';
function handleAndroidMessage(
- message: AndroidForegroundMessage,
+ message: AndroidMessage,
updatesCurrentAsOf: number,
handleIfActive?: (
threadID: string,
@@ -56,8 +56,8 @@
function getCommAndroidNotificationsEventEmitter(): NativeEventEmitter<{
commAndroidNotificationsToken: [string],
- commAndroidNotificationsForegroundMessage: [AndroidForegroundMessage],
- commAndroidNotificationsNotificationOpened: [AndroidForegroundMessage],
+ commAndroidNotificationsMessage: [AndroidMessage],
+ commAndroidNotificationsNotificationOpened: [AndroidMessage],
}> {
return new NativeEventEmitter(CommAndroidNotificationsEventEmitter);
}
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
@@ -36,7 +36,7 @@
androidNotificationChannelID,
handleAndroidMessage,
getCommAndroidNotificationsEventEmitter,
- type AndroidForegroundMessage,
+ type AndroidMessage,
CommAndroidNotifications,
} from './android.js';
import {
@@ -161,7 +161,7 @@
this.handleAndroidDeviceToken,
),
commAndroidNotificationsEventEmitter.addListener(
- 'commAndroidNotificationsForegroundMessage',
+ 'commAndroidNotificationsMessage',
this.androidMessageReceived,
),
commAndroidNotificationsEventEmitter.addListener(
@@ -523,15 +523,13 @@
});
}
- androidNotificationOpened = async (
- notificationOpen: AndroidForegroundMessage,
- ) => {
+ androidNotificationOpened = async (notificationOpen: AndroidMessage) => {
this.onPushNotifBootsApp();
const { threadID } = notificationOpen;
this.onPressNotificationForThread(threadID, true);
};
- androidMessageReceived = async (message: AndroidForegroundMessage) => {
+ androidMessageReceived = async (message: AndroidMessage) => {
this.onPushNotifBootsApp();
const { messageInfos } = message;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 10:28 PM (21 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2581158
Default Alt Text
D7193.id24190.diff (7 KB)
Attached To
Mode
D7193: Save message instantly to redux for both foregrounded and backgrounded app
Attached
Detach File
Event Timeline
Log In to Comment