diff --git a/packages/messaging/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingSerializer.java b/packages/messaging/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingSerializer.java index 6f7213c0e0..e3a2f23465 100644 --- a/packages/messaging/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingSerializer.java +++ b/packages/messaging/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingSerializer.java @@ -21,6 +21,8 @@ public class ReactNativeFirebaseMessagingSerializer { private static final String KEY_ERROR = "error"; private static final String KEY_TO = "to"; private static final String KEY_TTL = "ttl"; + private static final String KEY_PRIORITY = "priority"; + private static final String KEY_ORIGINAL_PRIORITY = "originalPriority"; private static final String EVENT_MESSAGE_SENT = "messaging_message_sent"; private static final String EVENT_MESSAGES_DELETED = "messaging_message_deleted"; private static final String EVENT_MESSAGE_RECEIVED = "messaging_message_received"; @@ -99,6 +101,8 @@ static WritableMap remoteMessageToWritableMap(RemoteMessage remoteMessage) { messageMap.putMap(KEY_DATA, dataMap); messageMap.putDouble(KEY_TTL, remoteMessage.getTtl()); messageMap.putDouble(KEY_SENT_TIME, remoteMessage.getSentTime()); + messageMap.putInt(KEY_PRIORITY, remoteMessage.getPriority()); + messageMap.putInt(KEY_ORIGINAL_PRIORITY, remoteMessage.getOriginalPriority()); if (remoteMessage.getNotification() != null) { messageMap.putMap( diff --git a/packages/messaging/lib/index.d.ts b/packages/messaging/lib/index.d.ts index 7d526ac7be..663c084b7b 100644 --- a/packages/messaging/lib/index.d.ts +++ b/packages/messaging/lib/index.d.ts @@ -147,6 +147,46 @@ export namespace FirebaseMessagingTypes { * Options for features provided by the FCM SDK for Web. */ fcmOptions: FcmOptions; + + /** + * Priority - android-specific, undefined on non-android platforms, default PRIORITY_UNKNOWN + */ + priority?: MessagePriority; + + /** + * Original priority - android-specific, undefined on non-android platforms, default PRIORITY_UNKNOWN + */ + originalPriority?: MessagePriority; + } + + /** + * Represents the priority of a RemoteMessage + * + * Note: this is an android-specific property of RemoteMessages + * + * See https://github.com/firebase/firebase-android-sdk/blob/b6d01070d246b74f02c42da5691f99f52763e48b/firebase-messaging/src/main/java/com/google/firebase/messaging/RemoteMessage.java#L57-L64 + * + * Example: + * + * ```js + * firebase.messaging.MessagePriority.PRIORITY_NORMAL; + * ``` + */ + export enum MessagePriority { + /** + * Unknown priority, this will be returned as the default on non-android platforms + */ + PRIORITY_UNKNOWN = 0, + + /** + * High priority - Activities may start foreground services if they receive high priority messages + */ + PRIORITY_HIGH = 1, + + /** + * Normal priority - Activities have restrictions and may only perform unobtrusive actions on receipt + */ + PRIORITY_NORMAL = 2, } /**