- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我可能在这里遗漏了一些明显的东西。
如何创建一个 CloudKit 通知,其中包含有关您收到通知的 CKRecord 的详细信息? (即不仅仅是通用的“新项目已创建!”而是带有记录标题的通知,例如“Jill 和 Jessica 的生日派对!”)
正确的方法是为每个新记录更改创建一个带有新 notification.alertBody 的新订阅吗?这没有任何意义。
留下选项 queryNotification.recordID 将数据从 CloudKit(或我的本地存储)中拉出并以某种方式将其添加到通知中?添加或更改已通知通知的值的方法是什么?我错过了什么?
更新:根据 Edwin 的建议,这里有一个代码片段,但它不起作用。
let notification = CKNotificationInfo()
notification.alertBody = "Added: %@" as NSString
notification.alertLocalizationArgs = ["name"]
最佳答案
只需填写 CKNotificationInfo 对象的 .alertLocalizationArgs
.alertLocalizationArgs 的文档说:
Use of this property is optional. This property contains an array of NSString objects, each of which corresponds to a field of the record that triggered the push notification. Those names are used to retrieve the corresponding values from the record. The values are then used to replace any substitution variables in either the alertBody or alertLocalizationKey strings. The values themselves must be NSString, NSNumber, or NSDate objects. Do not specify keys with other values. String values that are greater than 100 characters in length may be truncated when added to the push notification.
If you use %@ for your substitution variables, those variables are replaced by walking the array in order. If you use variables of the form %n$@, where n is an integer, n represents the index (starting at 1) of the item in the array to use. Thus, the first item in the array replaces the variable %1$@, the second item replaces the variable %2$@, and so on. You can use indexed substitution variables to change the order of items in the resulting string, which might be necessary when you localize your app’s messages.
以下是我如何使用它的 2 个示例:
notificationInfo.alertBody = "%1$@ : %2$@"
notificationInfo.alertLocalizationArgs = ["FromName", "Text"]
第二个样本:
notificationInfo.alertLocalizationKey = "News: %1$@"
notificationInfo.alertLocalizationArgs = ["Subject"]
在 Localizable.strings 文件中,您将“News: %1$@”作为键
更新:看起来您现在需要使用 .alertLocalizationKey。所以第一个样本不再起作用。
关于ios - CloudKit 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27371588/
要在私有(private) CKRecordZone 中添加 CKRecord,您需要确保该区域已经存在。 但这是否意味着每次我需要插入记录时,我都需要获取所有区域并使用 fetchAllRecord
我正在与 cloudkit 仪表板交互并查看我的应用程序收集的数据。 如何从仪表板导出所有数据(数据 -> csv 或 json),以便我可以对其进行一些分析? 谢谢! 最佳答案 我认为苹果永远不会提
我使用 Cloudkit 和私有(private)数据库将一些文件存储到 iCloud 并在 iOS 和 OSX 之间同步。现在我想实现一些东西,用户可以在不离开应用程序并查看首选项的情况下查看他的
我有两个看起来像这样的 CloudKit 数据对象: 父对象: { "records": [ { "recordName": "14102C0A-60F
有谁知道这个闭包中的String字段的用途public var recordWithIDWasDeletedBlock: ((CKRecordID, String) -> Void)?。我不知道它的用
我的应用程序在 CloudKit 中执行的几乎所有操作现在都会返回此错误: (lldb) po [error userInfo] { CKDHTTPHeaders = {
我在尝试初始化 Cloudkit schema 时遇到此错误: Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occur
我正在更新 iOS13 之前的 Core Data 应用程序以使用 Core Data+CloudKit 同步来支持多个设备上的单个用户。同步应该是自动发生的,并且在我开发的一个中间步骤中它确实起作用
有没有办法使用 CloudKit 获取 iCloud 笔记?我看过文档: https://developer.apple.com/library/archive/documentation/DataM
swift 3.1,Xcode 8.3.3 我在 CloudKit 中有一个名为 Aircraft 的记录类型,它有一个名为 fieldValues 的字段,类型为 Reference List。 在
swift 3.1,Xcode 8.3.3 我在 CloudKit 中有一个名为 Aircraft 的记录类型,它有一个名为 fieldValues 的字段,类型为 Reference List。 在
当我尝试从 CloudKit Dashboard 查询 CloudKit 时,收到一条错误消息: There was a problem querying the “Entry” type. no a
出于某种原因,一小部分 iOS 10 用户无法从我的公共(public) iCloud 容器中读取数据。 CloudKit 返回的 localisedError 是“Account doesn't h
我有一个在 iOS 上运行良好的应用程序,但是当使用催化剂运行时,如果我在 macOS 上滑动到另一个虚拟桌面,然后再返回大约 10 次,它会间歇性地崩溃。它主要发生在 UICollectionVie
用户 B 从用户 A 拥有的共享记录中删除自己的正确方法是什么?我想我记得从一些 WWDC 视频中用户 B 会删除 CKShare来自他的共享数据库,但在查看用户 A 设备的权限时,该用户似乎仍然是参
对于我们的消息传递应用程序,如果我们将用户消息直接发送到 CloudKit (不做任何我们自己的加密),我们可以声称我们的应用程序是 end-to-end encrypted ,“只有通信用户可以阅读
我之前曾尝试使用 OSX/iOS 应用程序实现 CloudKit,由于我的强制症,我非常担心设备之间某些数据的优先级,以及可能丢失数据或恢复已删除的数据。 我的逻辑是,将从 iCloud 获取的数据和
Apple 发布了一种针对 CloudKit 的服务器到服务器进行身份验证的新方法。 https://developer.apple.com/library/content/documentation
因此根据Apple的文档,未登录iCloud的用户仍然可以从公共(public)数据库中读取数据,但是在查询公共(public)数据库时,我收到以下错误: Error Domain=NSCocoaEr
我需要创建一个CKQuery,其中谓词包含记录的引用,而不是记录的字段。 像这样 let query = CKQuery(recordType: "OUP", predicate: NSPredica
我是一名优秀的程序员,十分优秀!