0

This is my scenario:

My application is not launched yet at that time app receives push notification from APN which delegate method get called;

what I read:

1. If app is in background or foreground DidReceiveRemoteNotification get called.

2. If app is not launch yet then the notification will be received in banner if i click on it. App will launch from didFinishLaunching with notification option.

user1725145
  • 3,993
  • 2
  • 37
  • 58
jailani
  • 2,260
  • 2
  • 21
  • 45
  • http://stackoverflow.com/questions/5056689/didreceiveremotenotification-when-in-background – Retro Jul 04 '14 at 11:21
  • Sorry, what is the question exactly? If the app is launched from a notification and is not currently running it will, as you write, launch with the `didFinishLaunchingWithOptions:` method. – T. Benjamin Larsen Jul 04 '14 at 11:25
  • @nickfalk My question is, if the app receives a push notification but the app is not launched yet then which delegate method will get called – jailani Jul 04 '14 at 11:35
  • Ah, OK got you. Sorry but there are no delegate calls in this scenario as the app is dead as a Dodo. It is after all not the App that actually creates the push-notification on the device but the OS... – T. Benjamin Larsen Jul 04 '14 at 11:44
  • So We can't increment the app's badge number if the app is not launched yet right? – jailani Jul 04 '14 at 11:46
  • Right, it's one of the quirks of the service. – T. Benjamin Larsen Jul 04 '14 at 11:48
  • Please see accepted answer of this link http://stackoverflow.com/questions/11153631/increment-the-push-notification-badge-iphone he mentioned that didremotenotificationreceived will be called even if app is killed.. – jailani Jul 04 '14 at 11:54
  • You could look into the `UIBackgroundModes` which has a `remote-notification`option. (Haven't looked into this myself in detail, but I believe you need to send 'content-available' with the payload). – T. Benjamin Larsen Jul 04 '14 at 11:54

2 Answers2

0

You can try silent push notification. If app is in killed state, slient push notifications will be called. Silent push will call delegate in any state. you need pass: 'content-available' => '1' with the payload for silent notification. Just the limit is it supports ios7 and higher.

Esha
  • 1,328
  • 13
  • 34
-1

if i understand your question correctly then solution below when your application is not launched yet (not runnable state) that time there is not delegate method called (there is no delegate method available.)

if you want to do something after receiving push notification at that time (not runnable state or suspended state) IOS 7 provide two method

" setMinimumBackgroundFetchInterval: "
"application:performFetchWithCompletionHandler:"

Mahesh
  • 317
  • 1
  • 3
  • 17
  • Ok if you are correct means(there is no delegate method available) how will you update the badge number of your application if it is not launched yet – jailani Jul 04 '14 at 11:31
  • when provider send badge in payload to device, ios system automatically update badge.you need to clear badge number to 0. in didfinishLaunchingwithOption method. – Mahesh Jul 04 '14 at 12:24