简体   繁体   中英

How does WhatsApp handle silent push notifications on iOS when app was killed by user?

From what I've learned, silent push notifications do not call application:didReceiveRemoteNotification:fetchCompletionHandler: when the user killed the app via multitasking UI. But when looking at WhatsApps behavior, I do not understand how they manage to do the following:

  • mute a channel
  • force quit WhatsApp
  • receive a message in the muted channel
  • badge is shown
  • what's even more surprising =>
  • without launching WhatsApp, start Airplane mode
  • now launch WhatsApp => the text is shown at the right place

this means that WhatsApp somehow manages it to handle the receiption of the push notification although the app is killed. Does anyone have an idea how? With .badge , .alert , ...?

There are other methods to update your application. One other way is using background app refresh . Background App Refresh lets your app run periodically in the background so that it can update its content.

--Edit for adding other possible methods:--

An other way that can be used for a short period(fixed length time) after the app has been killed is by asking for background execution time . This can give the app more running time.

For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background . For example Apps that support Voice over Internet Protocol (VoIP) or Apps that Acts as a Bluetooth LE accessory.

--Edit #2 --

It seems from the info.plist of the WhatsApp application that it uses multiple UIBackgroundModes, any of them can be used to wake/keep the app in the background.

portion of info.plist of the WhatsApp:

<key>UIBackgroundModes</key>
<array>
    <string>audio</string>
    <string>fetch</string>
    <string>remote-notification</string>
    <string>voip</string>
</array>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM