gpt4 book ai didi

ios - 使用 CKSubscription/CKNotificationInfo 显示通知特定消息?

转载 作者:行者123 更新时间:2023-11-29 01:44:54 25 4
gpt4 key购买 nike

我想通知用户一条聊天消息已从其他用户发送,通知的正文应该是消息。是否可以通过 CKSubscription/CKNotificationInfo 进行设置?类似于 alertBody,但特定于每条消息。知道怎么做吗?

let s2 = CKSubscription(recordType: recordType, predicate: NSPredicate(format: "destination = %@", CKReference(recordID: CKRecordID(recordName: loggedInUserSettingRecordName!), action: .DeleteSelf)), options: .FiresOnRecordCreation)
s2.notificationInfo = CKNotificationInfo()
s2.notificationInfo.alertBody = " "
s2.notificationInfo.soundName = UILocalNotificationDefaultSoundName
subscriptionsToSave.append(s2)

最佳答案

您可以像这样在警报中使用参数:

s2.notificationInfo.alertLocalizationKey = "Message from %1$@ : %2$@"
s2.notificationInfo.alertLocalizationArgs = ["FromName", "Text"]

由于这是一条本地化消息,您还需要将其添加到 Localizable.strings

"Message from %1$@ %2$@ : %1$@" = "Message from %1$@ %2$@ : %1$@";

关于ios - 使用 CKSubscription/CKNotificationInfo 显示通知特定消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32033995/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com