I setup PushNotification.onNotification from @aws-amplify/pushnotification like so:
if (notification.foreground) {
console.log('notification received in foreground ', notification);
} else {
console.log('notification received in background ', notification);
}
if (PushNotificationIOS !== undefined) {
notification.finish(PushNotificationIOS.FetchResult.NoData);
}
});
On Android it's working fine. On iOS I can't trigger the onNotification/onNotificationOpened events, although I receive the notifications. There is a special case when I send the "Standard Message" via Pinpoint -> Test Messaging, which actually triggers the function, and when I log the notification it looks like this
'notification received in background ',
{ _data:
{ remote: true,
notificationId: '45BAA2A6-8676-402E-8E6B-03A69173AC8C' },
_remoteNotificationCompleteCallbackCalled: false,
_isRemote: true,
_notificationId: '45BAA2A6-8676-402E-8E6B-03A69173AC8C',
_alert: { title: ' test', body: 'qwerty' },
_sound: undefined,
_badgeCount: undefined,
_category: undefined,
_contentAvailable: 1,
_threadID: undefined }
(the notification was received in the foreground, but the message doesn't contain that info, so it prints as background. Both foreground/background will trigger the event when using Pintpoint -> Test messaging -> Standard message). Also Pinpoint Raw message does not work. SNS Identical / custom payload does not work.
I have augmented AppDelegate as according to https://github.com/react-native-push-notification-ios/push-notification-ios#augment-appdelegate
Anybody knows if amplify expects a certain payload in order to trigger the event? Or if something else could be causing this..?
Structures tested so far:
The SNS custom structure
"APNS_SANDBOX": "{\"aps\":{\"alert\":\"Sample message for iOS development endpoints\"}}"
}
Pinpoint raw message
{
"APNSMessage": {
"aps": {
"alert": ""
}
},
"GCMMessage": {
"data": {
"message": ""
}
},
"ADMMessage": {
"data" : {
"message": ""
}
},
"BaiduMessage": {
"title":"",
"description": ""
}
}