Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
OvsTim opened this issue Mar 23, 2023 · 5 comments

Comments

@OvsTim
Copy link

OvsTim commented Mar 23, 2023

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(),
  );
  });
@ilsafarber
Copy link

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
Copy link

same issue with 8.0.0 emui

@SebastianBranZapata
Copy link

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
Copy link

NFSMONSTR commented May 15, 2024

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants