hms-push-serverdemo-nodejs icon indicating copy to clipboard operation
hms-push-serverdemo-nodejs copied to clipboard

We are not getting Notification into HmsMessageService on onMessageReceived file in Android

Open binitpatel opened this issue 5 years ago • 2 comments

I am using your example send_notify_message.js file from HUAWEI Push Kit(NodeJs). I get a success message in NodeJs log. { code: '80000000', msg: 'Success', requestId: '160213898154027353000507' }

I can see Notification appears at top of the mobile but somehow we are not able to see into our Android log.

Normally any notification comes it should be handled by HmsMessageService method onMessageReceived. Based on that we further take programmatic action.

But in Huawei Notification does not appear in HmsMessageService. Currently, we are not able to take any action.

We have also tried to send notification via HUAWEI Push Kit from app gallery. Then also it does not appear into HmsMessageService. It only shows on top of mobile but it is useless for us we can not take any programmatic action.

binitpatel avatar Oct 08 '20 06:10 binitpatel

Here is the link to HUAWEI Push Kit from the app gallery https://www.screencast.com/t/oAfcSIWq5J

binitpatel avatar Oct 08 '20 06:10 binitpatel

I am using your example send_notify_message.js file from HUAWEI Push Kit(NodeJs). I get a success message in NodeJs log. { code: '80000000', msg: 'Success', requestId: '160213898154027353000507' }

I can see Notification appears at top of the mobile but somehow we are not able to see into our Android log.

Normally any notification comes it should be handled by HmsMessageService method onMessageReceived. Based on that we further take programmatic action.

But in Huawei Notification does not appear in HmsMessageService. Currently, we are not able to take any action.

We have also tried to send notification via HUAWEI Push Kit from app gallery. Then also it does not appear into HmsMessageService. It only shows on top of mobile but it is useless for us we can not take any programmatic action.

I was working on React Native In my case, onMessageReceived was triggered only by DataMessages, at least it was I found out while testing this library.

From documentation here

image

Example of message that worked for me:

const payload = {
     // anything you want here
     test: 'test'
}

const notification = {
      title: 'Condivisione Messaggio',
      body: 'Message Shared',
    };

const message = {
      data: JSON.stringify({ ...notification, payload }), // added also this one for being sure will be passaed to onMessageReceived
      android: {
        collapse_key: -1,
        urgency: 'HIGH',
        ttl: '10000s',
        data: JSON.stringify({ ...notification, payload }), // this one is important
      },
      token: [
        pushChannel,
      ],
    };

despotes avatar Aug 02 '21 16:08 despotes