0

I got a question that i can't figure out a long time. I know that i can't sync my application in "not-running" state. But let me show a simple scenario:

  1. I killed WhatsApp. It's not running.
  2. I send a message from another device.
  3. Remote notification received and alert shown.
  4. I activated "plane mode" on receiver device.
  5. Then i launch WhatsApp.
  6. It can't sync messages because of "plane mode" but i saw new message that received with remote notification.

I tested this scenario on iOS 9 and iOS 10 devices. How does it posible? Can anyone explain this?

Daedelus
  • 266
  • 5
  • 14

1 Answers1

0

I think they are using Remote Notifications background mode.

"If your server sends push notifications to a user’s device when new content is available for your app, you can ask the system to run your app in the background so that it can begin downloading the new content right away. The intent of this background mode is to minimize the amount of time that elapses between when a user sees a push notification and when your app is able to able to display the associated content. Apps are typically woken up at roughly the same time that the user sees the notification but that still gives you more time than you might have otherwise."

This is from developer apple. You can read more detailed about it in this artice under "Using Push Notifications to Initiate a Download".

Hope it will help.

Stas Volskiy
  • 441
  • 2
  • 5
  • Thanks for your interest. I read this document and build an application which supports background fetch. But it's not awaking my app when it's on "not running" state. (Or i made something wrong.) You can see these are different terminologies background and not-running states. Ref: https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html#//apple_ref/doc/uid/TP40007072-CH2-SW6 – Daedelus Aug 11 '17 at 12:35
  • The idea of background fetch is that system will automatically wake up (run in background) your application. There is no chance to debug it. You can test it by making some calls to your backend and see if there was any. So even if app was not running, iOS will run it when you received remote notification. – Stas Volskiy Aug 11 '17 at 12:55
  • Yes, it should work. I will explain my code and maybe you can find out what i'm missing. 1-) I enabled the Remote notifications option from the Background modes section of the Capabilities tab in your Xcode project. 2-) I checked my application settings on my phone for "background refresh". 3-) There is content-available=1 in my payload. "{alert = "Test";badge = 1;"content-available" = 1;sound = "ring-ring.aiff";}" 4-) I implement to making calls to my backed in application:didReceiveRemoteNotification:fetchCompletionHandler: while app is not running. 5-) There was no call in my backend.. – Daedelus Aug 11 '17 at 13:52
  • Document says: "The payload’s aps dictionary must include the content-available key with a value of 1. The payload’s aps dictionary must not contain the alert, sound, or badge keys." I tried like that and it did not work too.. – Daedelus Aug 11 '17 at 14:20
  • Try to begin background task in application:didReceiveRemoteNotification:fetchCompletionHand‌​ler: and then download your content. Background task should keep your app alive in background mode for 3 minutes or until you finish it. – Stas Volskiy Aug 14 '17 at 11:05