Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

AWS Pinpoint Enhancement - picture message #2411

Merged
merged 3 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/android/com/adobe/phonegap/push/FCMService.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private String localizeKey(Context context, String key, String value) {
/*
* Replace alternate keys with our canonical value
*/
private String normalizeKey(String key, String messageKey, String titleKey) {
private String normalizeKey(String key, String messageKey, String titleKey, Bundle newExtras) {
if (key.equals(BODY) || key.equals(ALERT) || key.equals(MP_MESSAGE) || key.equals(GCM_NOTIFICATION_BODY)
|| key.equals(TWILIO_BODY) || key.equals(messageKey) || key.equals(AWS_PINPOINT_BODY)) {
return MESSAGE;
Expand All @@ -203,6 +203,9 @@ private String normalizeKey(String key, String messageKey, String titleKey) {
return COUNT;
} else if (key.equals(SOUNDNAME) || key.equals(TWILIO_SOUND)) {
return SOUND;
} else if (key.equals(AWS_PINPOINT_PICTURE)) {
newExtras.putString(STYLE, STYLE_PICTURE);
return PICTURE;
} else if (key.startsWith(GCM_NOTIFICATION)) {
return key.substring(GCM_NOTIFICATION.length() + 1, key.length());
} else if (key.startsWith(GCM_N)) {
Expand Down Expand Up @@ -249,21 +252,21 @@ private Bundle normalizeExtras(Context context, Bundle extras, String messageKey
Log.d(LOG_TAG, "key = data/" + jsonKey);

String value = data.getString(jsonKey);
jsonKey = normalizeKey(jsonKey, messageKey, titleKey);
jsonKey = normalizeKey(jsonKey, messageKey, titleKey, newExtras);
value = localizeKey(context, jsonKey, value);

newExtras.putString(jsonKey, value);
}
} else if (data.has(LOC_KEY) || data.has(LOC_DATA)) {
String newKey = normalizeKey(key, messageKey, titleKey);
String newKey = normalizeKey(key, messageKey, titleKey, newExtras);
Log.d(LOG_TAG, "replace key " + key + " with " + newKey);
replaceKey(context, key, newKey, extras, newExtras);
}
} catch (JSONException e) {
Log.e(LOG_TAG, "normalizeExtras: JSON exception");
}
} else {
String newKey = normalizeKey(key, messageKey, titleKey);
String newKey = normalizeKey(key, messageKey, titleKey, newExtras);
Log.d(LOG_TAG, "replace key " + key + " with " + newKey);
replaceKey(context, key, newKey, extras, newExtras);
}
Expand All @@ -274,7 +277,7 @@ private Bundle normalizeExtras(Context context, Bundle extras, String messageKey
String notifkey = iterator.next();

Log.d(LOG_TAG, "notifkey = " + notifkey);
String newKey = normalizeKey(notifkey, messageKey, titleKey);
String newKey = normalizeKey(notifkey, messageKey, titleKey, newExtras);
Log.d(LOG_TAG, "replace key " + notifkey + " with " + newKey);

String valueData = value.getString(notifkey);
Expand All @@ -289,7 +292,7 @@ private Bundle normalizeExtras(Context context, Bundle extras, String messageKey
// with the other "message" key (holding the body of the payload)
// See issue #1663
} else {
String newKey = normalizeKey(key, messageKey, titleKey);
String newKey = normalizeKey(key, messageKey, titleKey, newExtras);
Log.d(LOG_TAG, "replace key " + key + " with " + newKey);
replaceKey(context, key, newKey, extras, newExtras);
}
Expand Down
1 change: 1 addition & 0 deletions src/android/com/adobe/phonegap/push/PushConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public interface PushConstants {
public static final String TWILIO_TITLE = "twi_title";
public static final String TWILIO_SOUND = "twi_sound";
public static final String AWS_PINPOINT_BODY = "pinpoint.notification.body";
public static final String AWS_PINPOINT_PICTURE = "pinpoint.notification.imageUrl";
public static final String AWS_PINPOINT_PREFIX = "pinpoint.notification";
public static final String MP_MESSAGE = "mp_message";
public static final String START_IN_BACKGROUND = "cdvStartInBackground";
Expand Down