Skip to content

Instantly share code, notes, and snippets.

@majirosstefan
Last active August 9, 2022 13:22
Show Gist options
  • Save majirosstefan/7dae0201f3b23546d43c18a1783e1113 to your computer and use it in GitHub Desktop.
Save majirosstefan/7dae0201f3b23546d43c18a1783e1113 to your computer and use it in GitHub Desktop.
Expo Push Notification & AWS Pinpoint & AWS SNS Compatibility - Patch for React Native app that provides compatibility between AWS Pinpoint (used on serverside) and Expo-Notification library (used in mobile app).
diff --git a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java
index 0af7fe0..d7c0946 100644
--- a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java
+++ b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java
@@ -16,6 +16,10 @@ import expo.modules.notifications.notifications.model.NotificationContent;
public class JSONNotificationContentBuilder extends NotificationContent.Builder {
private static final String TITLE_KEY = "title";
private static final String TEXT_KEY = "message";
+
+ private static final String TITLE_PINPOINT_KEY = "pinpoint.notification.title";
+ private static final String TEXT_KEY_PINPOINT_KEY = "pinpoint.notification.body";
+
private static final String SUBTITLE_KEY = "subtitle";
private static final String SOUND_KEY = "sound";
private static final String BODY_KEY = "body";
@@ -62,7 +66,9 @@ public class JSONNotificationContentBuilder extends NotificationContent.Builder
protected String getTitle(JSONObject payload) {
try {
- return payload.getString(TITLE_KEY);
+ if(payload.has(TITLE_PINPOINT_KEY)){
+ return payload.getString(TITLE_PINPOINT_KEY);
+ } else return payload.getString(TITLE_KEY);
} catch (JSONException e) {
return null;
}
@@ -70,7 +76,9 @@ public class JSONNotificationContentBuilder extends NotificationContent.Builder
protected String getText(JSONObject payload) {
try {
- return payload.getString(TEXT_KEY);
+ if(payload.has(TEXT_KEY_PINPOINT_KEY)){
+ return payload.getString(TEXT_KEY_PINPOINT_KEY);
+ } else return payload.getString(TEXT_KEY);
} catch (JSONException e) {
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment