Tag: cloudkit

typesCKSubscriptionOptionsFiresOnRecordUpdate的CKSubscription不起作用

我用下面的代码设置了CKSubscription : NSPredicate *predicate = [NSPredicate predicateWithFormat:@"TRUEPREDICATE"]; CKSubscription *subscription = [[CKSubscription alloc] initWithRecordType:@"RecordTypeName" predicate:predicate subscriptionID:@"Subscription1" options:CKSubscriptionOptionsFiresOnRecordCreation | CKSubscriptionOptionsFiresOnRecordUpdate]; CKDatabase *privateDatabase = [[CKContainer defaultContainer] privateCloudDatabase]; [privateDatabase saveSubscription:subscription completionHandler:^(CKSubscription * _Nullable subscription, NSError * _Nullable error) { if (error) { NSLog(@"Failed to subscribe."); } }]; 在application:didReceiveRemoteNotification:添加新logging时会收到通知,但在更新现有logging时,我永远不会收到通知。 我已经尝试从CloudKit仪表板和另一台login到同一帐户的设备更新logging。 我正在testingiOS 9testing版5。

针对CKReference的CloudKit预订通知未按预期工作

我试图设置一个CKSubscription的logging,其中包含一个CKReference字段的字段给用户。 但是,无论何时创buildlogging,都会忽略compoundPredicate的这一部分,并且通知永远不会到来。 在CKSubscription的谓词中使用CKReference有什么不同吗? 我进入仪表板input一个新的logging下我自己的用户recordID(当在模拟器中运行另一个用户),因为我相信我读了如果logging来自设备,它将不会收到通知。 任何洞察力都非常感谢,因为我已经坚持了一个星期,并找不到任何特定于此的任何事情。 我能够得到真正的types谓词通知,所以我认为我的基本设置是好的。 在仪表板中,我看到了两个testing用户的通用订阅,但没有任何用户的具体recordID(这是否重要?): Notifications.read (equals string) Notifications.user (equals reference) 当我执行fetchAllSubscriptionsWithCompletionHandler方法时,它会在debugging器中显示当前用户的特定recordID作为CKReference。 所以我不知道为什么不行。 这是我的代码,我首先创buildCKReference,然后用它作为我的谓词: var recordIDString = CKRecordID(recordName: "_a86dac8ee05f8c6ab35746bf9663d7b8") // I normally store this string in the NSUserDefaults. let userRef = CKReference(recordID: recordIDString, action: .DeleteSelf) let predicate = NSPredicate(format: "user = %@", userRef) let predicateTwo = NSPredicate(format: "read = %@", "") // I […]

在CloudKit中将logging从开发移到生产?

我有大量的logging手动预装到CloudKit,但在开发环境中。 在部署开发环境时,logging没有转移到生产环境中。 这真的很烦人。 任何简单的方法来移动logging?

将图像作为CKAsset存储在CloudKit中,图像颠倒

我正在开发一个使用CloudKit来存储和检索CKAsset对象的图像文件的应用程序。 通常情况下,这个工作很好,我喜欢CloudKit的小型学习曲线。 不过,我有一个特殊的问题,那就是,我的图像存储的时候是完全颠倒的,或者是左右90度。 这是一个存储不当的图像的例子: 我用我的iPhone 5拍了这张照片,纵向(我没有把原始图像保存到我的设备上,因为我只是想把它保存在云端,否则我也会在这里张贴原图。一个MacBook Pro坐在桌子上,你可以找出图片的原始意图)。 无论如何,我不仅有相机的新鲜图像,而且还有从我的照片库中select的图像的问题。 这里是我用来通过CloudKit存储图像的代码: let newRecord:CKRecord = CKRecord(recordType: "ImageProject") let imageData:NSData = UIImagePNGRepresentation(game.referenceImage)! let path = self.documentsDirectoryPath.stringByAppendingPathComponent(self.imageDirectoryName) imageURL = NSURL(fileURLWithPath: path) imageData.writeToURL(imageURL, atomically: true) UIImagePNGRepresentation(game.referenceImage)!.writeToFile(path, atomically: true) let imageFile:CKAsset? = CKAsset(fileURL: NSURL(fileURLWithPath: path)) newRecord.setValue(imageFile, forKey: "referenceImage") // Save the record into the public database if let database = self.publicDatabase { […]

CKContainer accountStatusWithCompletionHandler返回错误的值

accountStatusWithCompletionHandler方法返回.NoAccount值。 任何想法为什么返回的值不是。 .Available ? 我login到iCloud,并连接到互联网。 Doc说.NoAccount表示: 用户的iCloud帐户不可用,因为没有为此设备提供帐户信息。 我没有收到任何错误。 原因可能是该应用程序不使用私人数据库? Doc说: 在访问专用数据库之前调用此方法来确定该数据库是否可用。

CloudKit – 具有依赖性的CKQueryOperation

我刚刚开始与CloudKit合作,请耐心等待。 背景信息 在WWDC 2015上,苹果发表了一个关于CloudKit的演讲https://developer.apple.com/videos/wwdc/2015/?id=715 在这个谈话中,他们警告不要创build链式查询,而是推荐这种策略: let firstFetch = CKFetchRecordsOperation(…) let secondFetch = CKFetchRecordsOperation(…) … secondFetch.addDependency(firstFetch) letQueue = NSOperationQueue() queue.addOperations([firstFetch, secondFetch], waitUntilFinished: false) 示例结构 testing项目数据库包含宠物及其所有者,如下所示: |Pets | |Owners | |-name | |-firstName | |-birthdate | |-lastName | |-owner (Reference) | | | 我的问题 我试图find属于一个所有者的所有宠物,我担心我正在创build链苹果警告反对。 请参阅下面的两个方法来做同样的事情,但有两种方法。 哪个更正确或者都是错误的? 我觉得我正在做同样的事情,但只是使用完成块。 我很困惑如何改变otherSearchBtnClick:使用依赖。 我需要在哪里添加 ownerQueryOp.addDependency(queryOp) 在otherSearchBtnClick:? @IBAction func searchBtnClick(sender: AnyObject) { […]

该应用程序缺less必需的权利com.apple.developer.icloud-services'

我在我的应用程序中使用了一个公共的iCloud数据库,这个数据库效果很好,并在商店中使用。 在更新我的应用程序到一个新的版本(iOS9上的Xcode 7),我得到了一个崩溃的线: CKContainer * container = [CKContainer containerWithIdentifier:@"iCloud.com.identifier"]; *** Terminating app due to uncaught exception 'CKException', reason: 'The application is missing required entitlement com.apple.developer.icloud-services' 这只会在更新后第一次启动应用程序,并且仅在iOS9上发生。 在第一次(更新)启动后,应用程序启动和iCloud按预期工作。 我可以通过下载应用程序的当前商店版本,然后从Xcode 7运行更新的应用程序来始终重新创build崩溃。 如果我使用iOS8执行相同的步骤(下载生产应用程序和更新),则不会有相同的崩溃。 我猜这是一个iOS9或Xcode 7的错误。 有任何想法吗? 编辑:这实际上发生在iOS9上的应用程序的第一次启动,不pipe我是更新还是只是第一次安装。

使用Swift在CloudKit中获取logging资产

我是CloudKit的新手,我无法将数据库中的资源连接到我的应用程序中的ImageView和TextView。 在我的CloudKit数据库中,在loggingtypes下,我创build了一个名为“Companies”的logging。 然后我去了Public Data-> Default Zone,然后创build了一个名为“myCompany”的logging的新实例。 在“我的公司”我有两个资产,一个图像和一个.txt文件。 我想将这些资源连接到我的应用程序。 我不知道是否需要使用CKQuery或什么是最好的方法。 任何意见将不胜感激。 以下是我到目前为止。 随意给我反馈,或者如果有更好的方法,我很想知道。 谢谢。 import UIKit import CloudKit class LearnViewController: UIViewController { @IBOutlet weak var theImage: UIImageView! @IBOutlet weak var theText: UITextView! let myRecord = CKRecord(recordType: "Companies" ) var image: UIImage! let database = CKContainer.defaultContainer().publicCloudDatabase func loadCoverPhoto(completion:(photo: UIImage!) -> ()) { dispatch_async( dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)){ var […]

SWIFT:我没有从我的CloudKit应用程序收到通知?

我问这个问题,人们已经回答,但没有任何工作。 这对我来说是非常重要的,我可以得到这个工作。 这是我的一些代码: @IBAction func sendSweet(sender: AnyObject) { //delegate method let newSweet = CKRecord(recordType: "Extra1") newSweet["content"] = textField.text let publicData = CKContainer.defaultContainer().publicCloudDatabase publicData.saveRecord(newSweet, completionHandler: { (record:CKRecord?, error:NSError?) -> Void in if error == nil { dispatch_async(dispatch_get_main_queue(), { () -> Void in self.tableView.beginUpdates() self.sweets.insert(newSweet, atIndex: 0) let indexPath = NSIndexPath(forRow: 0, inSection: 0) self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Top) […]

iOS swift:使用coredata(cloudkit)存储caching

我正在学习使用cloudkit来保存和获取logging,但是我对将caching保存到coredata感到困惑。 例如,我提取了几个logging,并使用tableview显示这个loggingtypes的几个属性(比如A,C和F)。 当我单击一个单元格时,它将显示此logging的详细信息(此logging的所有属性:ABCDEF,但不包括引用属性logging)。 我想知道当我第一次提取logging时,是否应该将这些东西存储到coredata中:“ACF和recordID”? 而当用户点击查看详细信息,我再次使用recordID获取? 关键是我应该使用什么属性types来存储CKRecordID / CKRecord? 我知道我可以将图像存储到本地caching文件(也令人困惑的..),但它不是一个持久存储的权利? 而我之所以不直接存储logging的所有属性,是因为这个logging是一个“邀请”,只有当用户select接受它时,才会下载包括一些引用types属性的所有属性。 任何帮助将是有益的,谢谢!