|
14 | 14 | import com.pusher.pushnotifications.SubscriptionsChangedListener;
|
15 | 15 | import com.pusher.pushnotifications.PushNotificationReceivedListener;
|
16 | 16 |
|
| 17 | +import java.util.Map.Entry; |
| 18 | + |
17 | 19 | //
|
18 | 20 | // TODO: verify the android manifest after https://docs.pusher.com/beams/reference/android
|
19 | 21 | /**
|
@@ -57,18 +59,24 @@ public void onResume(final Activity activity) {
|
57 | 59 | public void onMessageReceived(RemoteMessage remoteMessage) {
|
58 | 60 | // Arguments.createMap seems to be for testing
|
59 | 61 | // see: https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeMap.java#L16
|
60 |
| - //WritableMap map = Arguments.createMap(); |
| 62 | + // WritableMap map = Arguments.createMap(); |
61 | 63 | final WritableMap map = new WritableNativeMap();
|
62 | 64 | RemoteMessage.Notification notification = remoteMessage.getNotification();
|
63 | 65 |
|
| 66 | + final WritableMap data = new WritableNativeMap(); |
| 67 | + for (Entry<String, String> entry : remoteMessage.getData().entrySet()) { |
| 68 | + data.putString(entry.getKey(), entry.getValue()); |
| 69 | + } |
| 70 | + |
64 | 71 | if(notification != null) {
|
65 | 72 | map.putString("body", notification.getBody());
|
66 | 73 | map.putString("title", notification.getTitle());
|
67 | 74 | map.putString("tag", notification.getTag());
|
68 | 75 | map.putString("click_action", notification.getClickAction());
|
69 | 76 | map.putString("icon", notification.getIcon());
|
70 | 77 | map.putString("color", notification.getColor());
|
71 |
| - //map.putString("link", notification.getLink()); |
| 78 | + map.putMap("data", data); |
| 79 | + // map.putString("link", notification.getLink()); |
72 | 80 |
|
73 | 81 | context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(notificationEvent, map);
|
74 | 82 | //System.out.print(remoteMessage.toString());
|
|
0 commit comments