OneSignal / react-native-onesignal

React Native Library for OneSignal Push Notifications Service
Other
1.56k stars 373 forks source link

OneSignal.setNotificationOpenedHandler() showing different result in Huawei HMS compare to Android GMS #1251

Closed zarepp closed 3 years ago

zarepp commented 3 years ago

Description: I'm currently integrating OneSignal react-native plugin in both HMS and GMS environment, it seems like does not work in HMS environment in Huawei device without GMS. But it works in normal Android GMS device.

I able to get getDeviceState() returned values, but setNotificationWillShowInForegroundHandler() I can't get any values after test push messages from OneSignal server as well as using postman API.

Environment react-native-onesignal": "^4.0.6" gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99] com.huawei.agconnect:agcp:1.2.1.301 com.huawei.hms:push:4.0.3.300

Steps to Reproduce Issue:

  1. Open the app and stay in foreground
  2. Send a push notification to the app via OneSignal dashboard
  3. GetDeviceState is get called, with all required token, ids and states.
  4. Click on the notification.
  5. OneSignal.setNotificationOpenedHandler() triggered show result:

Android GMS

action: { type: 0 }
notification: {
  androidNotificationId: -978693883,
  body: "Test PN",
  fromProjectNumber: "XXXXXX",
  groupedNotifications: null,
  lockScreenVisibility: 1,
  notificationId: "fcdda39e-1bcb-4491-84c8-efa002466013",
  priority: 5,
  rawPayload: " 
{\"google.delivered_priority\":\"normal\",\"google.sent_time\":1624418099441,\"google.ttl\":259200,\"google.original_priority\":\"normal\",\"custom\":\"{\\\"i\\\":\\\"fcdda39e-1bcb-4491-84c8-efa002466013\\\"}\",\"pri\":\"5\",\"vis\":\"1\",\"from\":\"XXXXXXX\",\"alert\":\"Test PN\",\"title\":\"Test\",\"google.message_id\":\"0:1624418099473421%1d39a545f9fd7ecd\",\"google.c.sender.id\":\"XXXXXX\",\"androidNotificationId\":-978693883}",
  templateId: "",
  templateName: "",
  title: "Test"
}

Huawei HMS

action: { type: 0 }
notification: {
  androidNotificationId: 0,
  groupedNotifications: null,
  lockScreenVisibility: 1,
  notificationId: "52ed42f4-8026-4d71-902d-b9099552ec80",
  priority: 0,
  rawPayload: "{\"custom\":\"{\\\"i\\\":\\\"52ed42f4-8026-4d71-902d- b9099552ec80\\\"}\",\"_push_msgid\":\"-1375519372\",\"_hw_from\":\"XXXXXXXX\",\"_push_data_version\":\"1\",\"_push_notifyid\":785785607,\"_push_cmd_type\":\"cosa\"}",
  templateId: "",
  templateName: ""
}
syuhadazulkifli commented 3 years ago

Hello @rgomezp, I also facing the same issue as stated by @zarepp here. Seek your feedback and assistance regarding this issue. Thanks

syuhadazulkifli commented 3 years ago

Hi @rgomezp. We are still hoping to get feedback from your end. Thanks in advance.

ramosalx1504 commented 3 years ago

Hi, I am using version 4.2.0 and it seems that it has not been fixed yet.

OneSignal.setNotificationOpenedHandler() for HMS returns:

{ "rawPayload": "{\"custom\":\"{\\"i\\":\\"472e45f2-8bd2-4be3-b39e-049c93dd7ed7\\"}\",\"_push_msgid\":\"-1643710186\",\"_hw_from\":\"736430079245858662\",\"_push_data_version\":\"1\",\"_push_notifyid\":538084639,\"_push_cmd_type\":\"cosa\"}", "lockScreenVisibility": 1, "androidNotificationId": 0, "templateId": "", "priority": 0, "groupedNotifications": null, "templateName": "", "notificationId": "472e45f2-8bd2-4be3-b39e-049c93dd7ed7" }

syuhadazulkifli commented 3 years ago

Hi

Howdy, We were seeing some issues with the foreground handler but they got fixed in 4.1.1.

Please upgrade to the latest version.

Enjoy!

@rgomezp The issue still has not been fixed yet with v4.2.0. Body & title still missing in rawPayload. Please advice us with any suggestion to cater this issue.

rgomezp commented 3 years ago

Howdy,

Thanks for your patience everyone.

So unfortunately it looks like Huawei doesn't provide what was displayed on the notification such as the title and body text. However, as a workaround, you can add anything you choose as additional data and it will be provided in the payload.

Hope the workaround helps.

Enjoy!