I tried everything and read all topics, but I can’t find out why NSUbiquitousKeyValueStore is not stored in iCloud.
• Created a specific application identifier
• Included iCloud in this app id
• Provisioning profile created
• Enable iCloud in the project
• Set the rights to the key value: $ (TeamIdentifierPrefix) $ (CFBundleIdentifier)
• Enabled iCloud Drive on the device
But NSUbiquitousKeyValueStore only stores locally. When I reinstall the application, it does not receive information from iCloud.
This is how I try:
NSUbiquitousKeyValueStore *cloudStore = [NSUbiquitousKeyValueStore defaultStore]; if ([[cloudStore stringForKey:@"testString"] length] == 0) { NSLog(@"Nothing in iCloud - setting a value..."); [cloudStore setString:@"I'm live in iCloud!" forKey:@"testString"]; [cloudStore synchronize]; [[NSUbiquitousKeyValueStore defaultStore] synchronize]; } else { NSString *result = [cloudStore stringForKey:@"testString"]; NSLog(@"Found something in iCloud - here it is: %@", result); } [self registerForiCloudNotificatons];
If I delete the application or try on the new device, it will not find anything in iCloud.
So, I tried this to find out if iCloud works:
NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; if (ubiq) { NSLog(@"iCloud at %@", ubiq); } else { NSLog(@"No iCloud access, %@", ubiq); }
And this always returns “no iCloud access”, and I can’t understand why. No matter what I do, the URLForUbiquityContainerIdentifier always returns zero.
I work on iOS 8 devices with iCloud enabled.
Did I miss something?
Thanks!