我想通知用户已经从另一个用户发送了聊天消息,并且通知的主体应该是消息。它是用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)发布于 2015-08-16 10:51:35
您可以在警报中使用如下参数:
s2.notificationInfo.alertLocalizationKey = "Message from %1$@ : %2$@"
s2.notificationInfo.alertLocalizationArgs = ["FromName", "Text"]由于这是一条日志化消息,所以还需要将其添加到Localizable.strings中。
"Message from %1$@ %2$@ : %1$@" = "Message from %1$@ %2$@ : %1$@";https://stackoverflow.com/questions/32033995
复制相似问题