0
votes

I'm realy confused about this subject, my question is simple: when the application: didReceiveRemoteNotification: fetchCompletionHandler: will be called?

  1. if the application is running and in foreground ? i test and the response is yes for iOS 7 and no in iOS 6 as described in the function comment.

  2. if the application is in background and running ? response: same as 1.

  3. if the application is in background but suspended by the system ?

  4. most importent point: if the application is killed (not in the "multitask view")?

how i activate/handel the notification :

  1. add the remote motif in xcode capabilities section (in info.plist).
  2. ask to register :

[[UIApplication sharedApplication] registerForRemoteNotificationTypes: UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeNewsstandContentAvailability]

3 . implement the delegate method. (add inside completionHandler(UIBackgroundFetchResultNewData);)

when i send a notification (with the content-available key==1) :

  1. if the app is in foreground/background and running the function is triggered and the code inside is performed (i download an image and save it in documents folder).
  2. if the app is killed, the image is not downloaded.

second question : have you any easy why to debug remote notification background mode?

[edit] after tests, if the app is suspended (we add a loop to log date) it receive the notification and try to trigger code, but the app is stopped after 1 seconde, have we miss a parameter to encase duration ? (as i read the maximum is 30 secondes).

1
it's a little hard to read your question as you have many other question nested in that post. is there a way you can simplify thismeda

1 Answers

0
votes

Sorry to answer my own question, to be simple the remote notification is only handled when the application is in background(active/suspended).

[EDIT]: if you want to have a push notification that awake the app even if it is killed take a look at PushKit but this only possible if you have VOiP feature in your app.