通过发送push消息来更新你的app。
总览
PushKit框架通过直接给你的app发送特定种类的消息来进行处理相关事务,这些消息有VoIP邀请,watchOS并发(complication)更新,文件提供者更改消息(file provider change notifications)。你可以在PKPushType中看到完整的supported notification种类列表。
由UserNotifications支持的用户消息会被present给用户,而PushKit消息机制不会这样,它不会present badges ,alerts 或sounds。
PushKit消息机制相比UserNotification有如下优势:
- 如果你的app没有处于运行状态,系统会在收到通知后自动启动它。虽然你也可以通过UserNotification的silent模式来后台更新你的app,但你的app不能保证会在收到消息时启动。你可以在Local and Remote Notification Programming Guide找到更多相关信息。
- 你的app会被交由runtime来处理消息,即使他运行在后台。
- 为了延长电池寿命,设备只有在收到PushKit消息时才会被唤醒。
- PushKit消息可以携带比user notification更多的数据。
如果你想要为你的app注册PushKit消息机制,请参照Enable push notifications中的内容。
如果你想找到更多关于配置和使用PushKit的内容,请查看What's New in the Apple Push Notification Service。