react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
734 stars 282 forks source link

Extra params not delivered #336

Closed akinncar closed 2 years ago

akinncar commented 2 years ago

I'm trying to send extra params on my notification like this

APNS: JSON.stringify({ 
      aps: {
        alert: {
          title,
          body: 'Hello Notification'
        },
      },
      email: 'hello@test.com'
    }),

but I'm not able to receive when debugging notification param on onPushNotification. see the result:

{
  "actionIdentifier": "com.apple.UNNotificationDefaultActionIdentifier",
  "badge": null,
  "body": "Hello notification",
  "category": "",
  "date": "2021-09-21T10:56:04.547-03:00",
  "identifier": "45CE238F-B686-49B1-9F01-EG24E437482E0",
  "sound": null,
  "subtitle": null,
  "thread-id": "",
  "title": null,
  "userInfo": {
    "actionIdentifier": "com.apple.UNNotificationDefaultActionIdentifier",
    "aps": {
      "alert": "Hello notification"
    },
    "userInteraction": 1
  }
}

email param shouldn't be in userInfo?

akinncar commented 2 years ago

the problem is that I was missing APNS_SANDBOX to test on sandbox, see the solution:

APNS_SANDBOX: JSON.stringify({ 
    aps: {
        alert: {
          title,
          body: 'Hello Notification'
        },
      },
      email: 'hello@test.com'
    }),