I have my Push Notification running. It works. I receive a notification and use
application:didReceiveRemoteNotification:
to get the incoming data and then send the user to the necessary screen.
Problem is, if you are using the App and a notification is received, it jumps to the destination screen without giving any alert/sound/anything.
I could put an alert in application:didReceiveRemoteNotification:
, but then that alert would appear every time, not just when the app is running.
Ideas about how to handle this?
Push notifications do not require a particular application to be open on a device for the message to be received by the end user, so a smartphone user can see notifications even when their phone is locked, or an app is not running. The end user must opt-in to receive push notifications from a given application.
Let's start with Android. The Android OS is designed to listen for push messages and upon receiving one, wake up the appropriate Android app to handle the push message, regardless of whether the app is closed or not.
Apple does not offer a way to handle a notification that arrives when your app is closed (i.e. when the user has fully quit the application or the OS had decided to kill it while it is in the background). If this happens, the only way to handle the notification is to wait until it is opened by the user.
I would recommend checking the applicationState property in UIApplication to determine if the app is running in the background or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With