Saving CloudKit Record “Not Authenticated” (9/1002)“ ”This request requires an authenticated account“”

你。 提交于 2019-12-04 15:59:36

问题


Saving a CKRecord in the simulator gives me the following error:

                [publicDatabase saveRecord:cloudRouteEntity
                     completionHandler:^(CKRecord *record, NSError *error) {
                         if (error) {
                             NSLog(@"An error occured in %@: %@", NSStringFromSelector(_cmd), error);
                             abort();
                         } else {

                             dispatch_async(dispatch_get_main_queue(), ^(void) {
                                 //gui
                                 NSLog(@"Created Cloudkit Entity");

                             });
                         }
                     }];

However, it works on the phone. Why does the simulator not have access to the CloudKit database?

EDIT: I thought I'd be clever by adding the iCloud account to the simulator - but iCloud moans that this is not allowed on "this device" (simulator). Ideas anyone?


回答1:


I got the same problem, which I was able to resolve by logging in to my iCloud account in the simulator (Settings > iCloud).

As of the latest Xcode, you can log in to your iCloud account in the simulator, and everything should work.

If you are having trouble logging in, try to go to iCloud.com on a desktop and log in there first. Once that is set up properly, then try in the simulator.




回答2:


I'm seeing the same error. According to the discussion linked below the cause might be two-factor authentication.

https://discussions.apple.com/thread/6588883




回答3:


Because folks might misinterpret the approved answer (as I did) here is a little more detail to get through this (you can use keyboard shortcuts but I am specifying menu selections for clarity):

  1. Run simulator (Xcode) - Run an app from Xcode in the simulator by selecting Product > Run
  2. App Home Screen (Simulator) - Within the simulator, navigate to the Home screen by selecting Hardware > Home
  3. Settings App (Simulator) - Find the settings app (gear), run it and select iCloud
  4. Authenticate (Simulator) - Enter your credentials and login (or re-login if your credentials have changed) to iCloud. Once you do this you can re-run your app and it should properly authenticate to iCloud

Once you do this you are good to go for future builds and runs.




回答4:


I had similar issue unless I did login into Settings app/iCloud section on my iPad Retina iOS8.1.1




回答5:


I was having the same problem.

I has added an id query index in the Users Records, when i removed this index the problem stopped.

I dont even know whats the relation between these things, but it worked for me.

Sorry for the bad english




回答6:


Reset the simulator completely (make sure nothing is left), re-install it. Maybe you got a wrong bit version? If possible, try if it works on a other PC or Laptop.

I tested it and i was able to connect to iCloud so i am pretty sure its something about your settings / wrong install etc.



来源:https://stackoverflow.com/questions/26253415/saving-cloudkit-record-not-authenticated-9-1002-this-request-requires-an-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!