Issues Listening to Incoming Notifications with native, raw device token (standalone app)

Hey @ide!

I’ve found the way to doing this, but I think it’s highlighted a bug in Expo’s codebase.

Firstly, the solution. In our situation, we use AWS and SNS Mobile Push to send push notifications from our service, and the payload is required in the following format:

{
  body: Object, // the data you want to send with the notification
  message: String, // the notification body
  notificationId: Int, // some ID number
  isMultiple: Boolean,
  remote: Boolean
}

You can construct this with the following Java code, as an example:

payload.put("body", dataMap);
payload.put("message", notification.getMessage());
payload.put("notificationId", -1);
payload.put("isMultiple", false);
payload.put("remote", true);

I am happy to provide more details on the solution to this to anyone else who’s using native device tokens with Expo - the best place to find me is by direct messaging me on the Expo Developers Slack; my username is josh-es.

Secondly, the bug. The payload received by the Notifications listener in the JavaScript code looks like this when using our push notifications service:

I then tried the same thing using the Expo push service:

Notice that the message property is being set to the same object as the data property, which is working as intended? Surely in theory the message property should be set to the notification text, and the data property set to the data object passed to the Expo push service, or the equivalent in a native notification payload? There are notices in the codebase about this being deprecated (in the ExponentNotification class linked to above), but is there some other way to access notification messages via the Notifications.addListener handler in the JavaScript?