Expo Notification ReceivedListener Wrong Data on Ios

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": ...
}

@adamjnav, sorry to bother, can someone help clarify if it is really a bug your I lost some info on docs?

@adamjnav, more info about de Ios Native Code:

I’ve recentely opened an issue on GitHub Native Objective C Code:

But I’ve done a workarround and created a fork of expo-notification :

Issue

https://github.com/expo/expo/issues/10070

Workarround

https://github.com/expo/expo/pull/10071

@wodin, do you know someone that can help me solve this?

Hi

You’re more likely to get an answer on Monday, but hopefully someone sees your issue or your PR before then.

Unfortunately I haven’t played around with this myself, but I agree it seems wrong for the Android and iOS behaviours to return different structures of data.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.