OnMessageReceived Not Triggered When Application Closed (HMS Pushkit) - xamarin

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 :
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.

Related

Silent push not received (APNS) after fore quitting app

Do we have any alternative for chatting app becuase iOS silent push notifications are highly highly unreliable, for example
if the app was terminated by the user they are not delivered at all
if the battery power is <= 40%, the OS receives the push but often delays delivering it to the app for a few minutes
if the batter pwer is >= 20, the OS receives the push but decides not to forward it to the app at all
many other criteria affect whether the OS actually delivers the push to the app or not
We tried using Voip push to achieve smooth chatting behavior for apps not suspended state. But the problem is in iOS 13 its must to report incoming call on voip push arrival.
Do we have any other option or way around so that chatting apps like ours can work in background/suspended state (for short time)?
If your server has all the information you need to write the notification text, you can send regular push notifications that won't wake up your app.
There's no other way than using silent push notifications to run your app in background, but one alternative is to use Notification Service app extension. It won't wake up your app, only this app extension, but you'll be able to write code for it to modify the notification text before presenting it to the user
It's possible to share data between your app and this extension - by sharing the database or just some data using app groups or the keychain. Your app extension will only have 30 seconds to run, but that should be enough.
Silent push notifications are unreliable and should not be used to notify about a new message.
VoIP pushes are exclusive for reporting incoming calls.

Observe for new System Notifications OSX

Is it possible to listen/observe for new notifications macOS receives?
I mean like when a new iMessage or a Slack message is received (so basically everything that causes NotificationCenter to display a Notification)
Short answer: It is not possible.
You can't observe user notifications sent by applications unless an application provides a specific API. For example the AppleScript dictionary of iMessage and Mail contains events scripts can respond to. However user notifications are encapsulated in the target application.
There is a global notification class named DistributedNotificationCenter, a notification dispatch mechanism that enables the broadcast of notifications across task boundaries. Some processes are sending distributed notifications but it's a completely different functionality as UserNotification. For example the TimeMachine engine process backupd sends distributed notifications while running a backup.
You can subscribe for all distributed notifications with
DistributedNotificationCenter.default().addObserver(self, selector: #selector(handleNotifications(_:)), name: nil, object: nil)
but I doubt that iMessage sends a distributed notification when a message is received.

Testing techniques for Apple Push Notification Gateways

I'm sure this must have been answered but i cant find it.
What are the techniques used to test a server side application that generates apple push notifications?
We have a host based service that waits on an event, and then generates an APN, and our IOS application will receives this notification.
So, I'd like to write a test that simulates the event being received and sends the APN and then determine if it was delivered. From what i understand, apple will does not support this?
Only think i can think of is to write an IOS application, that simulates the event has occurred and tells our host to send back a Push notification to the testing device. Then the IOS application could detect that it was received or not. We could put it on an IPOD touch that is always running in our server rack. I dont really like that approach but dont know what else to do.
If we used Urban Airship would that make it easier?
You can send push notification using below url :
http://pushwatch.com/apns/
You'll just need three thing as below :
1)Pem file
2)Device token(s)
3)Message

Sending real notification after toast received

In a project I'm currently working on, we send some small info across the wire to WP7 device when we send a raw notification.
When the application is in a tombstone state and the user receives the toast message, we can't add the extra baggage in the toast. So we figured we need a way to resend the notification once the user entered the application again.
Anybody has any experience or possible solution for this problem. We are currently looking at a sort of handshaking between client and server. But it all seems a bit drastic for me.
Kind regards,
Tom
I would suggest to stop using rawNotifications and use only toast.
To handle the case when the app has been started using a toast notification, query the server at app startup to check if there's pending data.
For notifications sent while the app is running, you can detect them using the ShellToastNotificationReceived event of your channel. When the event is triggered, query the server to retrieve the payload.

WP7 Push Notification - Power Management

Microsoft documentation says that if the battery power of the device is critically low then the app will not receive push notifications. If the battery power is low but not critically low then the app will receive only Raw notifications.
In these two cases an ErrorOccurred event is received, do we have to show an error message to the user explaining the what has happened. Is it fine displaying an error message when the battery level is low?
If you're not receiving messages on the phone, how will the app know to inform the user. Even if it isn't running.
When restarting the app you shoudl always check (and if necessary re-establish) channels.
If it's appropriate to let the user know there was a problem and it has now been fixed. And/or that previous notifications failed then you should do so.

Resources