2

我正在尝试在我的 iOS 应用程序中实现丰富的通知,并且在使用Notification Service ExtensionNotification Content Extension时,运行我的应用程序后我收到相同捆绑标识符的错误。对于这些扩展,我是否需要使用单独的配置文件?比如我的代码一个,通知服务扩展一个,通知内容扩展一个?

4

2 回答 2

2

是的,您必须为Notification Service Extension 和 Notification Content Extension使用单独的配置文件。作为参考,您可以使用此链接。

https://mobisoftinfotech.com/resources/mguide/ios-10-rich-notifications-tutorial/

服务扩展:

服务扩展的入口点类 UNNotificationServiceExtension

它覆盖了 2 种方法:

func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
}

func serviceExtensionTimeWillExpire() {
}

内容扩展的入口点类是 UIViewController,它实现了协议

func didReceive(_ notification: UNNotification) {
}
于 2018-06-19T10:05:40.277 回答
0

是的,您需要为 Notification Service Extension创建单独的证书(开发和发布) 。

在此处输入图像描述

此外,您应该包括mutable-content键并在您的有效负载中设置true,如下所示。

{
    "aps": {
        "alert": {
            "title": "test title",
            "body": "test message"
        },
        "mutable-content": 1
    },
    and more...
}
于 2021-12-27T04:57:43.250 回答