1

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!

  • "close" and "background" are two different things. Which scenario are you testing? – Jason Jun 11 '21 at 15:38
  • I'm testing the scenario for which when the application is explicitly closed by the user, I believe the correct technical term might be "killed", not force stopped though, I know notifications don't function in that case. – Clifton Steenkamp Jun 11 '21 at 21:20
  • if the user kills the app it's not running period, so I would not expect any code to fire – Jason Jun 11 '21 at 21:55
  • Alright I understand that, is there anyway around it? Because for e.g with FCM I'm easily able to handle notifications, even if a user closes the application. – Clifton Steenkamp Jun 13 '21 at 14:14
  • I have no idea, I have never used PushKit. I would refer to their docs or support forums for help – Jason Jun 13 '21 at 17:16
  • Hi@Clifton Steenkamp,What is the EMUI version of your phone?could you pls provide your hms appid for us to check?And also pls capture logcat logs when sending messages – zhangxaochen Jun 15 '21 at 01:29

1 Answers1

1

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 :

https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/funtion-description-0000001050148080

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.

Zinna
  • 1,947
  • 2
  • 5
  • 20