I am developing an iOS app that uses CloudKit. Apple's documentation says that I should use NSFileManager's ubiquityIdentityToken property to detect whether the service is available. But the property is always nil. How can I do to solve it? I am testing my app on an iPhone 5 simulator with iOS 8.2. And I have also logged into an iCloud account. I have also turned on iCloud Drive. (Someone says that turning on iCloud Drive may solve this problem, but this doesn't work for me.)
Do I need to call NSFileManager's method URLForUbiquityContainerIdentifier:? But Apple's documentation says that it is needed for document storage. It doesn't say that it is needed for CloudKit.
The CKContainer accountStatusWithCompletionHandler method is how you should check whether the user is logged into iCloud or not (supported since iOS 8.0). The CloudKit Quick Start shows an example of how to use it. fetchUserRecordIDWithCompletionHandler is another option that might make sense for your app.
In iOS 9.0, you'll also have CKAccountChangeNotification, which will notify your app when the iCloud status on the device changes.
Related
Look at this Apple Docs
Additionally, iOS automatically forwards a read-only copy of your iOS
app’s preferences to Apple Watch. Your WatchKit extension can read
those preferences using an NSUserDefaults object, but it cannot make
changes directly to the defaults database.
Is there anyone know how to access iOS app's preferences from Apple Watch and how often it is updated on the Apple Watch.
I did try to search for document, but could not found any.
AFAIK, NSUserDefaults can contain upto much memory. It would be bad if iPhone try to save all this user config in NSUserDefault onto the watch.
They don't. You should use the WatchConnectivity framework. Here is an extended answer: Reading NSUserDefaults in watchOS 2 (I know App Groups doesn't work)
I've integrated CloudKit into my iOS app and I'm encountering functionality inconsistency between devices.
One of my users has an iPod 5th Gen and an iPhone 6. If they use the iPod everything works as expected. However if they use the iPhone 6 they can only receive data and notifications, they can't make changes of their own. When the iPhone attempts to make changes to the iCloud public database I receive no errors and changes are made locally, they just never make it to the server (everything appears to work, it just doesn't).
Given that the user can use the iPod successfully but the same iCloud account only receives data on the iPhone suggests to me that this might be a permissions or settings issue.
I've checked:
User is logged into iCloud
iCloud drive is on
The app appears enabled in the iCloud Drive menu in settings
The app appears enabled under the "Look Me Up By Email" menu
Other details:
The app is available through TestFlight
The app is using the production container (required for TestFlight)
I don't know what code to supply because the app functions as expected on other devices but let me know what could help. Any help would be greatly appreciated.
This was resolved by changing my modify operations qualityOfService property to .UserInitiated.
After I reviewed the completion handler for my CKModifyRecordsOperation I realized that I was saving data necessary for local functionality regardless of whether the completion handler received an error or not (and incidentally, whether it was executed or not). So when it appeared to me that my operation was being run and returning no errors, it actually wasn't being run at all. Changing the qualityOfService appears to have resolved this.
Answer that led to the solution
i am trying to implement an App with iCloud Key-value storage feature.
Currently, I'm testing it from two devices iPhone5s with iOS7.0.4 and iPhone4 with iOS6.1.1.
Do you guys have any idea why the same iCloud account (checked from Settings -> iCloud -> Account) gets two different ubiquityIdentityToken? i guess this is the reason the data didn't sync between this two devices (network accessed).
And on iOS6, NSUbiquitousKeyValueStoreDidChangeExternallyNotification is not trigging.
Thanks in advance!
The ubiquityIdentityToken is only intended to be used to:
Determine if iCloud is available to your app
Determine if the iCloud account has changed (by comparing to a previously saved value).
It's opaque but conforms to a few protocols. You can save it locally and compare the current value with a previous value, but that's about all it's good for. It's not guaranteed to be useful in any other situation.
It's not guaranteed to be the same on different devices, even if those devices use the same iCloud account. Why it might be different is not documented-- it might encode a device-specific value somehow. Regardless, it's not something that you can transfer from one device to another and expect to still be useful. That's not how it's designed to work.
It does encode a device-specific value in the token. The 8-digit hexadecimal number groups between positions 17 and 22 change on a different device OR with a different iCloud account.
The rest of the groups usually remain the same, across different apps, devices, OR iCloud accounts.
This is strange behaviour. In these cases Apple usually recommends signing out and logging again (using the same Apple ID) on both devices. Try that and see if it helps. Also, make sure to install the latest version of your app (with enabled iCloud) on every device.
I'm looking for a way to retrieve the UDID on devices running iOS 6+ (Enterprise deployment only - no app store limitations).
Calling the (now private) method uniqueIdentifier returns the 'vendorIdentifier' starting with 'FFFFFFF'. Unfortunately thats not what I want.
Any ideas? Is there another private method or something?
Thanks in advance.
I recommend you reading this article. To sum up:
The previously deprecated uniqueIdentifier now works like vendorIdentifier on iOS 7+, so it's no longer usable even for Enterprise Apps
OpenUDID cannot be shared between Applications on iOS 7+ and now can change. It's still usable but no longer recommended.
The vendorIdentifier hasn't changed, but it's not recommended for Enterprise Apps because it can change when updating the App.
The new advertisingIdentifier API is the way to go for new Apps. It's the same for all Apps and should not change frequently, but the user can reset it in the settings page.
Edit: Website udid.io obtains the real Device UDID instead of the obfuscated one if you need it for anything outside your App. If you need the UDID from within the App, see my answer above.
You can get a Unique UDID via this method using private api. Follow this link
Look for the code in accepted answer.
Sorry, but Apple warned it would be deprecated and it has been. I've had the same headache myself.
I can't help you identify the device in the same way Apple do, but you can always generate an unique UUID on app launch and stash that away in KeyChain. It won't be perfect, but it will persist between installations and will be unique to the device. As far as I know, that's the current solution
I have an iOS app reading native phonebook and save them into a local sqlite3 db. you know in iOS6, a new feature named privacy setting is added in system.
so my question comes, how to check privacy setting for my app on reading contact is disabled?
is there any notification sent?
I searched lots of sites but no good result. Currently my app's behavior is,
disable reading contact, when app is switch from background to foreground, or re-launch sometimes(other times works.), contact still showed in my app's list.
Thanks in advance!
now iOS 6 is open to public. I tried and found that is simple. check address book is nil is fine.This is work for iOS release version.
For previous prerelease version, it is not always true. it may return 0 contact number. Anyway, it is not the end user version.