Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which delegate method gets called when using Push Notifications if application is in background state?

Reading from Apple's documentation about Push Notifications:

  1. As a result of the presented notification, the user taps the action button of the alert or taps the application icon. If the action button is tapped, the system launches the application and the application calls its delegate’s application:didFinishLaunchingWithOptions: method
  2. The notification is delivered when the application is running in the foreground. The application calls its delegate’s application:didReceiveRemoteNotification: method

So my question is which delegate gets called if the application is in background state (it is running or it's suspended)? Is it application:didFinishLaunchingWithOptions: or application:didReceiveRemoteNotification:?

Please help me, thank you!

like image 496
Mahesh Avatar asked May 25 '11 08:05

Mahesh


People also ask

Which delegate method is called when I click on app icon in background?

application:didReceiveRemoteNotification: is called when your app is in the background.

How does a push notification system work?

A push service receives a network request, validates it and delivers a push message to the appropriate browser. If the browser is offline, the message is queued until the the browser comes online. Each browser can use any push service they want, it's something developers have no control over.

What is background push?

A background push notification is a silent, remote notification that helps keep your app's data up to date. Unlike regular push notifications, background push notifications do not show app icon badges, trigger a sound, or display a message when received by your app.


2 Answers

application:didReceiveRemoteNotification: is called when your app is in the background. This question has an answer which tells you how to tell if your app was in the background or not.

like image 112
Amy Worrall Avatar answered Sep 20 '22 14:09

Amy Worrall


application:didReceiveRemoteNotification: is called when your app is in the background + the message alert still active.

Once the message alert is inactive then the application will not receive any event. Do correct me if I'm wrong.

like image 42
Water7 Avatar answered Sep 16 '22 14:09

Water7