0

Is it possible to have foreground push come in, but not receive push notification when the app is in background?

I've had some users report this problem and was wondering what could be the cause. Maybe it's just confusion? Please enlighten me if anyone else had the same problem and if so what the cause was. Thank you!

Vlad
  • 8,038
  • 14
  • 60
  • 92
  • When the app is in the background, you really don't have any control over what happens. When the push comes in, the OS handles the push first and then sends the data to your app to process. – Chris Jan 09 '15 at 19:40
  • Yes, so does that mean it is theoretically impossible to have foreground push update but not background push notification? – Vlad Jan 09 '15 at 19:48
  • I'm pretty sure that's the case. I tried to do the same thing in a project a few months ago, but came to the conclusion after a day of research that it's not possible. – Chris Jan 09 '15 at 19:55

2 Answers2

0

Perhaps you could exclude the alert in the payload dictionary of the push. This might prevent the message from being displayed on the device you push to. You could however include a message in the dictionary using a custom key . If you have not registered for background fetch, then it should not update the content of your app when the app is in background. In the didReceiveRemoteNotification method of your App delegate you can create a UIAlertView to show to the user by referring to the custom key. I guess it depends on what actions you are trying to prevent when the user receives the push.

Josh Gafni
  • 2,831
  • 2
  • 19
  • 32
0

Since iOS 7.0, there is a new message that your UIApplicationDelegate can respond to when a push notification arrives while the app is in the background: In addition to the application: didReceiveRemoteNotification:, there is now a method application: didReceiveRemoteNotification: fetchCompletionHandler:.

The older method is only called while the app is in foreground or when the user slides the notification sideways on the lock screen. The new method with the additional fetchCompletionHandler: parameter is always called. Have a close look at the reference, which describes a few important details on how to respond to this message.

s.bandara
  • 5,636
  • 1
  • 21
  • 36