【发布时间】:2019-06-21 08:42:45
【问题描述】:
我有一个通知内容扩展的实现,它使用 iOS 打开时提供的默认通知内容(底部的两个文本行):
问题是当一个新的通知到达时UNNotificationContentExtension 被打开页脚的标题和正文字符串没有得到更新。我检查了方法didReceive() 是否被再次正确调用,并且传递的UNNotification 具有正确的更新信息(参数notification.request.content.body 和notification.request.content.title)。然而,操作系统似乎只是忽略了它们,即使我们可以毫无问题地更新内容本身,底部的文本也不会改变。
是否可以强制更新默认内容?似乎没有任何参数和/或方法可供我们使用...
提前感谢您的任何回复。
编辑:我还应该补充一点,通知是在本地生成的(APN 尚未激活)。代码如下所示:
UNMutableNotificationContent *notificationContent = [UNMutableNotificationContent new];
notificationContent.categoryIdentifier = @"my.notification.category";
notificationContent.title = @"My notification title";
notificationContent.body = @"My notification body";
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:notificationUUID
content:notificationContent
trigger:notificationTrigger];
UNUserNotificationCenter *notificationCenter = [UNUserNotificationCenter currentNotificationCenter];
[notificationCenter addNotificationRequest:request withCompletionHandler:nil];
【问题讨论】:
标签: ios usernotifications usernotificationsui