0

I have a very perplexing problem: I am unable to connect to iCloud while running my app on an iPad in XCode 7.1 debugger. This is my code to check to see if I have a iCloud connection:

    //  do we have a connection?
    id currentiCloudToken = [[NSFileManager defaultManager] ubiquityIdentityToken];
    NSURL *url = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:@"iCloud.com.pragerphoneapps.BookstoreInventoryManager"];
    id myContainer = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier: nil];

Each of these statements returns 'nil' as a result of the method calls. I have looked at all of my settings, both in XCode and the iPad device. I have run out of things to check.

Are there any docs out there that would give me a list of things to look for? (I've checked on SO, Google, iCloud Programming Guide and the iCloud Design Guide, but found nothing.

I have tried to change the iCloud id, but can't find any directions on how to do that. When I try to sign in to iCloud from my iPad, it keeps asking me for my Apple Id password, which I enter (I know it's good because I have reset it four (4) times today), and it keeps asking and finally locks me out again!

I would really appreciate some ideas on this.

SpokaneDude
  • 4,856
  • 13
  • 64
  • 120
  • No code will work until you are fully logged into iCloud on the device. – rmaddy Dec 07 '15 at 22:58
  • Hi Rick... Right... and when I go to the device and my iMac, it appears that I am signed in because there is a red "Sign Out" at the bottom of both – SpokaneDude Dec 07 '15 at 23:02
  • The state of your Mac is irrelevant here since you are running an iOS app on an iPad. So if you run the Settings app on your iPad and go to the iCloud screen, you see your name and email at the top and a Sign Out button at the bottom? If so, then you are logged into iCloud on the iPad. – rmaddy Dec 07 '15 at 23:05
  • OK... then shouldn't the *app* be able to connect to iCloud on the iPad? What could be some of the causes that would prevent it from connecting? (is there a list somewhere?) – SpokaneDude Dec 07 '15 at 23:13
  • Start by handling the `NSUbiquityIdentityDidChangeNotification` notification. See if that is called. But if you are logged in then `[[NSFileManager defaultManager] ubiquityIdentityToken]` shouldn't be `nil`. – rmaddy Dec 07 '15 at 23:17
  • Also make sure the iCloud capability is enabled for your app. – rmaddy Dec 07 '15 at 23:18
  • After messing with both the iPad and iMac all day, I have determined that I can access iCloud using the same account on both devices (iPad and iMac) using iCloud.com on the Mac. When I try this code in my app, I get 'nil' for all three methods. 'id currentiCloudToken = [[NSFileManager defaultManager] ubiquityIdentityToken]; NSURL *url = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:@"iCloud.com.pragerphoneapps.BookstoreInventoryManager"]; id myContainer = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier: nil];' So, what or where do I check next? – SpokaneDude Dec 08 '15 at 04:18

0 Answers0