hms-react-native-plugin icon indicating copy to clipboard operation
hms-react-native-plugin copied to clipboard

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

Open OvsTim opened this issue 1 year ago • 5 comments

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

  • Platform: React-Native
  • Kit: Push
  • Libriary Version: 6.5.0-300
  • OS Version Android 12

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(),
  );
  });

OvsTim avatar Mar 23 '23 13:03 OvsTim

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.

ilsafarber avatar Sep 12 '23 11:09 ilsafarber

same issue with 8.0.0 emui

numandev1 avatar Oct 19 '23 21:10 numandev1

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.

SebastianBranZapata avatar Feb 05 '24 21:02 SebastianBranZapata

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

NFSMONSTR avatar May 15 '24 11:05 NFSMONSTR

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

itsmeshusha avatar Jul 10 '24 11:07 itsmeshusha