Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling Push Notification While App is Open

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?

like image 740
Chris Avatar asked Nov 13 '10 03:11

Chris


People also ask

Does an app need to be open for push notifications?

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.

Do push notifications work when app is closed?

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.

Do push notifications work when app is closed iOS?

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.


1 Answers

I would recommend checking the applicationState property in UIApplication to determine if the app is running in the background or not.

like image 187
raidfive Avatar answered Sep 22 '22 22:09

raidfive