Dhaval Patel
Dhaval Patel

Reputation: 648

iOS Notification : How does WhatsApp receive notification and process even after force closing them?

I am building an iOS App ( Using Swift) where I want like to process Notification even though my app has been closed (force closed).

My Question : If as per Apple documentation if App can not process the notification if it is not running then how Whatsapp has managed to do so.

How can I achieve same behavior at my app ?? I will highly appreciate for right technical solution and I believe there are hundreds of developers might have same query.

Upvotes: 3

Views: 1684

Answers (1)

Paulw11
Paulw11

Reputation: 114965

As WhatsApp is a VoIP application, it is entitled to use PushKit:

PushKit notifications differ from the ones you handle using the UserNotifications framework. Specifically, PushKit notifications never display alerts, badge your app's icon, or play sounds. They also have the following advantages over user notifications:

  • The device wakes only when it receives a PushKit notification, which can improve battery life.
  • Upon receiving a PushKit notification, the system automatically launches your app if it isn't running. By contrast, user notifications aren't guaranteed to launch your app.
  • The system gives your app execution time (potentially in the background) to process PushKit notifications.
  • PushKit notifications can include more data than user notifications.

Note the second bullet point.

If your app meets the criteria for PushKit use (VoIP app, Watch Complication update or file provider update) then you can use it.

Update

In iOS 13 and later an app must report an incoming CallKit call in response to a VoIP push or it will be terminated. This means that in general VoIP or PushKit pushes cannot be used for messaging or other purposes, but WhatsApp doesn't do this. How?

They have a restricted entitlement com.apple.developer.pushkit.unrestricted-voip.

This entitlement is not granted any more and was intended to give apps with millions of users more time to adopt the new approach.

Upvotes: 6

Related Questions