通过通知中心使用 APNS VOIP(不受官方支持)Use APNS VOIP through Notification Hubs (not officially supported)

可以通过 Azure 通知中心使用 APNS VOIP 通知;但是,此方案不受官方支持。It is possible to use APNS VOIP notifications through Azure Notification Hubs; however, there is no official support for this scenario.

注意事项Considerations

如果仍然选择通过通知中心发送 APNS VOIP 通知,请注意以下限制:If you still choose to send APNS VOIP notifications through Notification Hubs, be aware of the following limitations:

  • 发送 VOIP 通知需要将 apns-topic 标头设置为应用程序捆绑 ID + .voip 后缀。Sending a VOIP notification requires the apns-topic header to be set to the application bundle ID + the .voip suffix. 例如,对于捆绑 ID 为 com.microsoft.nhubsample 的示例应用,apns-topic 标头应设置为 com.microsoft.nhubsample.voip.For example, for a sample app with the bundle ID com.microsoft.nhubsample, the apns-topic header should be set to com.microsoft.nhubsample.voip.

    此方法不太适用于 Azure 通知中心,因为应用的捆绑 ID 必须配置为中心的 APNS 凭据的一部分,并且不能更改值。This method doesn't work well with Azure Notification Hubs, because the app's bundle ID must be configured as part of the hub's APNS credentials, and the value cannot be changed. 此外,通知中心不允许在运行时重写 apns-topic 标头的值。Also, Notification Hubs does not allow the value of the apns-topic header to be overridden at runtime.

    若要发送 VOIP 通知,必须使用 .voip 应用捆绑 ID 配置单独的通知中心。To send VOIP notifications, you must configure a separate notification hub with the .voip app bundle ID.

  • 发送 VOIP 通知需要将 apns-push-type 标头设置为 voip 值。Sending a VOIP notification requires the apns-push-type header to be set to the value voip.

    为了帮助客户过渡到 iOS 13,通知中心会尝试推断 apns-push-type 标头的正确值。To help customers with the transition to iOS 13, Notification Hubs attempts to infer the correct value for the apns-push-type header. 推理逻辑已有意简单化,避免破坏标准通知。The inference logic is intentionally simple, in an effort to avoid breaking standard notifications. 遗憾的是,此方法会导致 VOIP 通知出现问题,因为 Apple 将 VOIP 通知视为特例,其遵循的规则不同于标准通知。Unfortunately, this method causes issues with VOIP notifications, because Apple treats VOIP notifications as a special case that does not follow the same rules as standard notifications.

    若要发送 VOIP 通知,必须指定 apns-push-type 标头的显式值。To send VOIP notifications, you must specify an explicit value for the apns-push-type header.

  • 通知中心根据 Apple 文档中的规定,将 APNS 有效负载限制为 4 KB。Notification Hubs limits APNS payloads to 4 KB, as documented by Apple. 对于 VOIP 通知,Apple 允许最大 5 KB 的有效负载。For VOIP notifications, Apple allows payloads up to 5 KB. 通知中心不区分标准通知和 VOIP 通知;因此,所有通知均限制为 4 KB。Notification Hubs does not differentiate between standard and VOIP notifications; therefore, all notifications are limited to 4 KB.

    若要发送 VOIP 通知,则不得超过 4 KB 有效负载大小的限制。To send VOIP notifications, you must not exceed the 4-KB payload size limit.

后续步骤Next steps

有关详细信息,请参阅以下链接:For more information, see the following links: