SDK Version: ^38.0.0
Expo Notifications: ~0.3.3
Platforms: Ios
The Problem
On Ios, the method addNotificationReceivedListener on Ios returns a notification with wrong data information.
the following notification.request.content.data
isn’t the same com Android
and iOS
Android
notification.request.content.data.scheduleID = rDFSDFyrwERTTdfsDsSA
notification.request.content.data.userId = fqeWtERGfdsSDfs
iOS
notification.request.content.data.scheduleID = null
notification.request.content.data.userId = null
How reproduce:
On Push Notification Tool — Expo
body = [{
to: ['ExponentPushToken[xxxAndroidxxx]','ExponentPushToken[xxxiOSxxx]'],
title: 'test',
body: 'test chrome console',
data: {"scheduleID": "rDFSDFyrwERTTdfsDsSA", "userId": "fqeWtERGfdsSDfs"},
priority: 'high',
sound: 'default',
ttl: 3000,
channelId: 'default'
}]
fetch('https://exp.host/--/api/v2/push/send', {
method: 'post',
body: JSON.stringify(body),
headers: { 'Content-Type': 'application/json' }
})
On React Native
import { addNotificationReceivedListener } from 'expo-notifications'
addNotificationReceivedListener(notification => {
console.warn(notification)
})
On Android addNotificationReceivedListener receives: [Right]
Object {
"date": 1599202933398,
"request": Object {
"content": Object {
"autoDismiss": true,
"badge": null,
"body": "test chrome console",
"data": Object {
"scheduleID": "rDFSDFyrwERTTdfsDsSA",
"userId": "fqeWtERGfdsSDfs",
},
"sound": "default",
"subtitle": null,
"title": "test",
},
"identifier": "0:1599202933404964%0ac519e6f9fd7ecd",
"trigger": ...
}
On iOS addNotificationReceivedListener receives: [Wrong]
Object {
"date": 1599202932.617644,
"request": Object {
"content": Object {
"attachments": Array [],
"badge": null,
"body": "test chrome console",
"categoryIdentifier": "",
"data": Object {
"aps": Object {
"alert": Object {
"body": "test chrome console",
"launch-image": "",
"subtitle": "",
"title": "test",
},
"category": "",
"sound": "default",
"thread-id": "",
},
"body": Object {
"scheduleID": "rDFSDFyrwERTTdfsDsSA",
"userId": "fqeWtERGfdsSDfs",
},
},
....
},
"identifier": "D5871CD7-8130-4AC6-8465-40CBC20A157F",
"trigger": ...
}