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

event onRemoteMessageReceived not fire #130

Closed
VChuharev opened this issue Jun 1, 2023 · 9 comments
Closed

event onRemoteMessageReceived not fire #130

VChuharev opened this issue Jun 1, 2023 · 9 comments

Comments

@VChuharev
Copy link

the event in Remote Message Received is not triggered at any state of the application.

plugin version 6.9.0-300
platform android 11.0.0

there is an event in Logcat:
javascript:hmsEventHandler('REMOTE_DATA_MESSAGE_RECEIVED', {"msg":{"collapseKey":"-1","data":"{'type':'intercom'}","dataOfMap":"{type=intercom}","messageId":"ABAAstMf5WR4QPhkeGgIAKY88UQ6eTcAAAA","originalUrgency":"1","urgency":"2","ttl":"10000","sentTime":"1685602552745","from":"99536292102848687","token":"IQAAAACy0x_lAADrYnZdzQRMjFn1DM_8hD4TcEqIsNgOiexmZRipoQER08RKZqhimHkYaYjPPJx1_vjhfqIhL4dOy83TLpqzVd1E1pnr_421WahJNg","receiptMode":"0","sendMode":"0","contents":"0","analyticInfo":"{\"biTag\":\"the_sample_bi_tag_for_receipt_service\"}","analyticInfoMap":"{biTag=the_sample_bi_tag_for_receipt_service}","titleLocalizationArgs":"[]","bodyLocalizationArgs":"[]","ImageUrl":"null","Link":"null","NotifyId":"0","When":"null","LightSettings":"[]","BadgeNumber":"null","Importance":"0","vibrateConfig":"[]","visibility":"null","isAutoCancel":"true","isLocalOnly":"true","isDefaultLight":"true","isDefaultSound":"true","isDefaultVibrate":"true"}})

@ilsafarber
Copy link

Hi @VChuharev,

If an uplink message is successfully sent by your app to your app server and the server responds to the message, a receipt will be sent to your app through the onRemoteMessageReceived() listener.

Have you enabled uplink message receiving through HTTPS in AppGallery Connect? This document may help you.

@VChuharev
Copy link
Author

Hi @VChuharev,

If an uplink message is successfully sent by your app to your app server and the server responds to the message, a receipt will be sent to your app through the onRemoteMessageReceived() listener.

Have you enabled uplink message receiving through HTTPS in AppGallery Connect? This document may help you.

Thk. But I need to get data in the application from a message sent from the server, and not vice versa.

@Cubaza
Copy link

Cubaza commented Jun 21, 2023

Hi,
I have same issue. @VChuharev have You maybe solve it? It's not working with data notification and even from example code downloaded from huawei :/

@VChuharev
Copy link
Author

Init new function

function hmsEventHandler(data, data2) {
  if(data2) {
    console.log(data2.msg;) 
  }
}

when the date push arrives, the application generates a call to this function, then what needs to be done.

@Cubaza
Copy link

Cubaza commented Jun 22, 2023

@VChuharev thank You very much. This was an issue and now everything is working fine. Thank You very much.

@iand2x2
Copy link

iand2x2 commented Jun 24, 2023

@Cubaza hi, may I know how did you fix it?

@Cubaza
Copy link

Cubaza commented Jun 26, 2023

@iand2x2 I've created new global function with body posted by VChuharev in this message:
#130 (comment)
So in my code it looks like this:

window.hmsEventHandler = function(eventName, payload) {
            if(eventName === 'REMOTE_DATA_MESSAGE_RECEIVED' && payload && payload['msg']) {
                HmsLocalNotification.localNotification({
                    [HmsLocalNotification.Attr.title]: payload['msg'].title,
                    [HmsLocalNotification.Attr.message]: new HmsPush.CordovaRemoteMessage(
                        payload['msg'].text
                    ).getDataOfMap(),
                });
            }
        }

That code make that when DATA push notification will be passed to application it will fire event and show notification. I know that there are more events which this code could broke, but for my purpose (showing notification on application) it is working.

@expcapitaldev
Copy link

@ozkulbeng hi, can you pls describe your changes here: cd174a8#diff-071540fd2096627b7119d04b04c24066fd2196aee261a0c2f34dbb9475e51bd4R50

if (window.hmsEventHandlers.hasOwnProperty(eventName)) { you changed to if (Object.prototype.hasOwnProperty(eventName)) {

what is mean here Object.prototype.hasOwnProperty ?
Looks like it is a critical bug and we can not receive any events because here we will have every time false.

// call
window.hmsEventHandler('NOTIFICATION_OPENED_EVENT', {});
//
// if (Object.prototype.hasOwnProperty(eventName)) {
//            window.hmsEventHandlers[eventName].forEach((handler) => {
//                handler(data);
//            });
 //       }

 // eventName -> NOTIFICATION_OPENED_EVENT
 // Object - ?
 // Object.prototype.hasOwnProperty(eventName) - false, 


@expcapitaldev
Copy link

fixed 2 days ago 758a6e7

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