I've integrated Huawei's Pushkit
, push notification service into my Xamarin application, I've tested the notifications while the application is running in the foreground and it works as expected.
However, while the application is closed the application and attempt to send a notification, the OnMessageReceived
method in my messaging service is not triggered.
According to the documentation that can be found here :
Regardless of whether your app is running in the foreground or background, if you override the onMessageReceived method in the DemoHmsMessageService class, your app can obtain the data message content as long as you send a data message.
According to me, that means the OnMessageReceived
method should be triggered, so long as you're sending a Data Message.
Am I missing something, or did I perhaps misinterpret the above-quoted passage?
Thanks In Advance! 😀
Push kit supports two types of messages - notification messages and data messages.
OnMessageReceived will be triggered for data message to receive message.
For data message, if app is closed, user might not receive message. As per doc :
The delivery of data messages depends on the resident status of your app. Push Kit cannot guarantee a high data message delivery rate, because it may be affected by Android system restrictions and whether the app is running in the background.
It might be because of battery optimization.
For Notification message, notification can be delivered regardless of app resident status, even if app is not launched.