HMS-Core / hms-react-native-plugin

This repo contains all of React-Native HMS plugins.
https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1
Apache License 2.0
241 stars 68 forks source link

[@hmscore/react-native-hms-push] Can't access notification data, when user tap notification #271

Open OvsTim opened 1 year ago

OvsTim commented 1 year ago

Description When we send notification + data via Huawei console we expect our app to trigger onNotificationOpenApp listener on notification press and we await, that in result will be passed notification data to perform some inner app logic.

Expected behavior When we tap notification - it fires onNotificationOpenApp and pass notification data to it

Current behavior When we tap notification - it fires onNotificationOpenApp and pass empty object "{ }" to it. Although, data messages, sended via console to HmsPushMessaging.setBackgroundMessageHandler works correctly and display all the data received.

Environment

Other

This is part of index.js file we used, we followed fully by Client Development section on site.

HmsPushMessaging.setBackgroundMessageHandler works correctly and print all passed data.

HmsPushEvent.onNotificationOpenedApp triggers, bit prints "{ }"

AppRegistry.registerComponent(appName, () => App);
HmsPushEvent.onNotificationOpenedApp(result => {
  console.log('onNotificationOpenedApp', JSON.stringify(result));
});

HmsPushMessaging.setBackgroundMessageHandler(dataMessage => {
  console.log('[Headless] DataMessage Received', dataMessage);
  console.log(
    '[Headless] DataMessage Received',
    new RNRemoteMessage(dataMessage).getData(),
  );
  });
ilsafarber commented 1 year ago

Hello @OvsTim I also use the same methods you mentioned, which works just fine in my application. I recommend you to use the latest Push kit. You can check the network or the proxy if you are using. If the problem still occurs, I will gladly try to help you.

numandev1 commented 11 months ago

same issue with 8.0.0 emui

SebastianBranZapata commented 8 months ago

I having the same Issue with React Native and Android 11. I get the push notification, but when I press I just get an empty object "{ }" as a result.

NFSMONSTR commented 4 months ago

I tested it on two devices (non huawei Android 14, with installed HMS Core and AppGallery and Honor 9 lite(Android 9, EMUI 9.1.0)). On Honor i got notification data from onNotificationOpenedApp, but on non Huawei device i got empty object instead of data. I noticed that even token format was different. It seems like on non huawei device i received fcm token(at least i think so), but on huawei device i received correct hms token. Probably this is source of problem

itsmeshusha commented 2 months ago

Hi, everyone! I'm also facing a similar problem. Testing on a real device - Huawei P40 lite (JNY-LX1, EMUI 12.0.0) "@hmscore/react-native-hms-push": "^6.12.0-301",

HmsPushEvent.onNotificationOpenedApp fails when opening notification from tray HmsPushMessaging.getInitialNotification() triggers but no push data in the response { "result": {}, "resultCode": "0"}