Closed 9r4ik closed 2 years ago
Hi @9r4ik ,
We have tested the push backgroundHandler with demo application. According to our recent tests, there are no buggy behaviour with version: 6.3.0.302.
We recommend you to try the latest updated version of React Native Push Kit. You should be careful with that, the setBackgroundMessageHandler must be declared at index.js. Otherwise it may not work properly.
HmsPushMessaging.setBackgroundMessageHandler((dataMessage) => {
HmsLocalNotification.localNotification({
[HmsLocalNotification.Attr.title]: "[Headless] DataMessage Received",
[HmsLocalNotification.Attr.message]: new RNRemoteMessage(
dataMessage
).getDataOfMap(),
})
.then((result) => {
console.log("[Headless] DataMessage Received", result);
})
.catch((err) => {
console.log(
"[LocalNotification Default] Error/Exception: " + JSON.stringify(err)
);
});
return Promise.resolve();
});
If the issue persist, contact us here. Thank you for your interest.
@ozcanozgur when send notification from pushkit console setBackgroundMessageHandler is called and notification is showing, When we send notification using REST API setBackgroundMessageHandler is not called, But notification alone showing in notification tray. Also notification not coming in foreground of the device.
But when application in foreground everything working as expected
Please find REST API Body:
{ "validate_only": false, "message": { "data": "{\"title\" : \"test\",\"body\" : \"This is Huawei Notification\",\"image\" : \"https://www.image.com\"}", "android": { "notification": { "title": "Welcome", "body": "This is Huawei Notification", "image": "https://www.image.com", "click_action": { "type": 3 }, "foreground_show": false } }, "token": [ "TOKEN" ] } }
Description
I send data-only push to my app. all pushes comes correctly, but when i force quit my app from memory, first push come but bakcgroundhandler don`t work. When i send 2-nd, 3-rd and others pushes: bakcgroundhandler work perfect.
Expected behavior First data-only push bakcgroundhandler work When i force quit app from memory
Current behavior First data-only push bakcgroundhandler work When i force quit app from memory
Logs BUNDLE ./index.android.js
WARN No task registered for key HMSPushHeadlessTask WARN No task registered for key HMSPushHeadlessTask LOG backgroundMessageHandler registered ✔
Environment