How to detect foreground/background mode after receiving the push notification on iOS? According to the documentation for the Android we can check if message property is empty. How to reach the same on iOS?
if (message === null || message === undefined) {
// Android messages received in the background don't include a message. On Android, that fact can be used to
// check if the message was received in the background or foreground. For iOS the message is always present.
title = 'Android background';
message = '<empty>';
}
Hi there @maciejkoch! In the PushNotificationReceived callback on iOS, there's no way to distinguish between these modes.
However, there are multiple options if you want to achieve that:
You can check out this comment in the thread. It is about React Native iOS SDK but the same applies to Cordova iOS SDK.
If you want pure ionic solution, you can check out multiple Stackoverflow questions on this, for example, setting pause/resume listeners
Description
Hi,
How to detect foreground/background mode after receiving the push notification on iOS? According to the documentation for the Android we can check if message property is empty. How to reach the same on iOS?
I use Ionic 4 with this plugin: https://ionicframework.com/docs/native/app-center-push
Repro Steps
Please list the steps used to reproduce your issue.
Details