voip app ios8: is pushkit still best practice?

2019-04-29 07:23发布

问题:

I am working on an app that needs reliable push messages (like any voip) under ios9. Here it says, that with IOS8+ one should use apns (registerForRemoteNotifications):

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/setKeepAliveTimeout:handler:

In the Optimize VOIP Apps document, Pushkit is preferred:

https://developer.apple.com/library/ios/documentation/Performance/Conceptual/EnergyGuide-iOS/OptimizeVoIP.html#//apple_ref/doc/uid/TP40015243-CH30-SW1

Does anybody have a clue on this? Or do they run the same code in the background?

回答1:

From the documentation for VoIP Push Notifications:

  • The device is woken only when VoIP pushes occur, saving energy.
  • Unlike standard push notifications, which the user must respond to before your app can perform an action, VoIP pushes go straight to your app for processing.
  • VoIP pushes are considered high-priority notifications and are delivered without delay.
  • VoIP pushes can include more data than what is provided with standard push notifications.
  • Your app is automatically relaunched if it’s not running when a VoIP push is received.
  • Your app is given runtime to process a push, even if your app is operating in the background.

The biggest advantage of VoIP Push Notifications over regular ones is in my opinion, that the app gets relaunched if it was force-closed.

In general, if you wan't to use the push notifications for VoIP functionality, e.g. to notify about an incoming call, use PushKit. It was developed for this purpose. For all other cases, use regular push notifications. Your app won't go through the review if you use PushKit for an app without VoIP functionality anyways.