iCloud synchronization does not work for an app on iPhone 4S and 5 - iphone

Summary:
Application installed on iOS (iPhone 4S or iPhone 5 - tested on both) that supports iCloud synchronization does actually not synchronize with iCloud. The iOS version is 6.1.2.
We are developing an application and added iCloud support. The provisioning profile was recreated with iCloud enabled and stored on the device. The entitlements were properly configured in xcode to use iCloud and a Key-Value Storage (the values for the identifier are set to defaults). We followed the Apple's iCloud Design Guide tutorial to implement functionality to sync with iCloud (using the NSUbiquitousKeyValueStore class to store and read values).
Steps to Reproduce:
Use an app with iCloud support (in development mode or an app installed from the App Store) on iPhone 4S or 5 (iOS 6.1.2 installed). Go to Settings > iCloud > Documents & Data and have Documents & Data enabled and Use Cellular Data disabled. Try to use the application with iCloud. The data are not synced between devices. We also tried as follows: run the application, store a value to iCloud, delete the application, install the application again, run the app, the value could not be retrived from the iCloud.
Turn off the iPhone and turn it back on.
Go to Settings > iCloud > Documents & Data and enable Use Cellular Data.
Now run the application with iCloud enabled and the value stored in the iCloud. The value is synced from the iCloud ... everything is working as it should.
Expected Results:
The iCloud synchronization works if Use Cellular Data is disabled and Document & Data is enabled in Settings > iCloud > Documents & Data.
Actual Results:
The iCloud synchronization will not work if Use Cellular Data is disabled in Settings > iCloud > Documents & Data.
Notes:
Also the notification NSUbiquitousKeyValueStoreDidChangeExternallyNotification has never fired the selector set unles the Use Cellular Data was enabled in Settings > iCloud > Documents & Data.
Could anyone reproduce the same behavior?
Could someone make iCloud sync to work with Use Cellular Data disabled in Settings > iCloud > Documents & Data?
Thanks in advance!

iCloud Key Value Storage is not reliable as it is expressed in iCloud Design Guide.
Data propagation might be delayed because of Key Value Storage throttling.
From the "Preferences and Settings" guide:
"The key-value store is intended for storing data that changes infrequently. If the apps on a device make frequent changes to the key-value store, the system may defer the synchronization of some changes in order to minimize the number of round trips to the server. The more frequently apps make changes, the more likely it is that later changes will be deferred and not show up on other devices right away."
Sometimes, due to this KVS throttling, NSUbiquitousKeyValueStoreDidChangeExternallyNotification doesn't fire, even if both Documents & Data option and Use Cellular Data option are enabled.
This might be your issue.
If not, you should wait for Apple staff to reply your bug report. (I suppose you have reported a bug, as your question is in Apple Bug Report format.)

Related

Disabling iCloud per app in iPhone Settings

I am using iCloud key-value storage in my app (ios 5.0+) and I wonder if it is possible to turn it on/off from within Settings/iCloud, similar way we can turn off Facebook/Twitter (per app) ?
I would prefer not to implement my own popups etc.
Best regards
In Settings -> iCloud -> Documents and Data you can enable / disable use of iCloud for Documents and Core Data on a per app basis, but not for iCloud key value storage.
If your app only uses iCloud key value storage it won't even appear in the list of apps on the settings pane.
So, the answer to your question is, no, it's not possible.

Delete local iCloud Data on Device (e.g. at first app launch/reinstallation)

If a user installs an an app which uses iCloud with a UI(Managed)Document, then uses the app, creates data which is saved to iCloud and then deletes the app on his phone, the iCloud data will stay on the device (transaction logs etc.). If the user reinstalls the app it will try to use these old files.
I have the following two problems with that:
The iCloud documents could have changed in the meanwhile and there might be problems when the user has no network connection on the first launch after reinstalling the app.
The iCloud documents for this app could have been deleted by the user (via settings or in Mac OS Finder in the user library). Now, when the user has no network on the first launch after reinstalling the app, the app might think that there is an ubiquity container with data even though it's already deleted (app might crash).
This is not very easy to test but I have definetely crashes and malfunctions for those two issues. E.g. NSMetadataQuery shows me results for documents which do not exist in iCloud because they have been deleted (but they existed on the deletion of the app).
Is there any easy solution to this? I thought about deleting the local iCloud data on the device when the app is launched for the first time - but how can this be done?
It can't be done. If you delete an iCloud document locally, you delete it everywhere-- eventually. The iCloud APIs have no concept of managing local copies independently of the iCloud service, so if you delete one-- even with the network down-- the iCloud ubiquity daemon will send a delete command to the service at the first opportunity.
The closest approximation that current APIs would allow would be:
Check whether the network is reachable
If it's not reachable, do not attempt to access any iCloud documents (because as you note, the information might be stale).
If and when the network comes up, try to open all existing iCloud documents. (On iOS, iCloud updates are only downloaded on demand, so you need to create that demand).
If that's not good enough (and let's face it, it's not good enough), file a bug with Apple and hope for the best.

iPhone iOS5 iCloud do both apps have to be open to receive each other's iCloud updates?

I'm testing a library-based iPhone app with iCloud enabled. With such app, changes to the core data persistent store are propagated across multiple devices.
What interests me is: Do iCloud "documents and data" changes are propagated across devices when the app that needs to be updated is closed?
Scenario: Device A makes changes, Device B's app is closed. Once the user restarts device B some time later, the changes are already present.
or
Does the app have to be open on additional devices to request data model updates?
Scenario: Device A makes changes to iCloud based core data stack. Device B's app comes online, checks if there are changes, requests changes to be downloaded.
Thank you for the clarification!
The former option is closer to the reality, but neither of your options describes the situation correctly.
The point is, if you use CoreData with the iCloud, the update will come whenever
your app is running
and the OS decides it's the right time to tell the app.
Your app then passively respond to what the OS tells you, as in any event-driven app development. Read Apple's documentation and/or related WWDC slides available again on Apple's developer website.
Also, Drew McCormack has a series of great blog posts on this topic, called "Under the sheets with iCloud and CoreData", starting here.

Is there a way to completely disconnect an App from iCloud?

My App can work with or without iCloud support.
If a user connects a device to iCloud and then wants to disconnect it, it's pretty easy for me to copy all data back to the local sandbox and stop using iCloud, and this device won't contribute anything new to iCloud anymore. However, changes from other devices will still be received (although not handled) on this device.
Is there a way to completely disconnect the device from iCloud, so that new changes won't be received?
iCloud stores data in a folder called "Mobile Documents." Your app's container resides in this folder. iOS devices know about new files and changes immediately. However, they do not actually download the file until the app specifically requests it. Here's an example scenario:
Someone is running your app on their iPhone and their iPad. They use iCloud on both. However, on their iPhone they disable your app's iCloud but leave their iCloud account active. This means that their device always knows about changes. But since your app never requests those documents, they are never downloaded to the device and therefore do not take up space. Also, iOS will automatically remove the local copy of an iCloud file to free up space if necessary.
For more information, see developer.apple.com/icloud, specifically the videos on how to use iCloud.
You can simply stop responding to the NSNotifications received by your app. You can either unregister your views from these notifications, or ignore them when they're received.

What folders and files gets backed up through iTunes?

Everytime I get a call my old wallpaper shows even though I have a new one. I'm trying to find it on my iOS but I cannot seem to figure out where. So I'm trying to track down what folders gets backed up when i backup my iPhone since I have restored it and it's still there.
(I'm using a jailbroken device)
I know this isn't the actual folder names and etc but it will give you an idea what it's backing up though. Good Luck.
With iOS 1.1 and later
Safari bookmarks, cookies, history,
and currently open pages
Map bookmarks, recent searches, and
the current location displayed in
Maps
Application settings, preferences,
and data
Address Book and Address Book
favorites
Calendar accounts
Wallpapers
Notes
Call history
Mail accounts
YouTube bookmarks
SMS messages
Saved suggestion corrections (these
are saved automatically as you reject
suggested corrections)
Camera Roll (photos and screenshots
taken by the iPhone)
Voicemail token (This is not the
Voicemail password, but is used for
validation when connecting. This is
only restored to a phone with the
same phone number on the SIM card.)
Web clips
Network settings (saved Wi-Fi
hotspots, VPN settings, network
preferences)
Paired Bluetooth devices (which can
only be used if restored to the same
phone that created the backup)
Keychain (this includes email account
passwords, Wi-Fi passwords, and
passwords you enter into websites and
some other applications. The keychain
can only be restored from backup to
the same iPhone or iPod touch. If you
are restoring to a new device, you
will need to fill in these passwords
again.)
With iOS 2.0 and later (in addition to the above)
Managed Configurations/Profiles
List of External Sync Sources (Mobile Me, Exchange ActiveSync)
Microsoft Exchange account configurations
Nike + iPod saved workouts and settings
App Store application data (except the application itself, its tmp and caches folder).
With iOS 3.0 and later (in addition to the above)
Videos in Camera Roll
Per app preferences allowing use of location services
Offline web application cache/database
Voice Memos
Autofill for webpages
Trusted hosts having certificates that cannot be verified
Websites approved to get the location of the device
In-app purchases
New with iOS 3.1: Videos in the Camera Roll that are 2 GB or larger are not backed up (iOS 4 and later will back up videos 2 GB and larger)
All user documents and settings get backed up, Application settings as well as system settings.
Applications each have a Documents folder that user data can be saved to, so thats pretty much what gets backed up for applications, including app preferences.
These are the Wallpaper locations:
/private/var/mobile/Library/SpringBoard/HomeBackground.jpg
/private/var/mobile/Library/SpringBoard/HomeBackgroundPortrait.jpg
/private/var/mobile/Library/SpringBoard/LockBackground.jpg
/private/var/mobile/Library/SpringBoard/LockBackgroundPortrait.jpg
I have manually managed to find out what gets backed up and managed to solve the problem :)
I downloaded the trial of iphone packup extractor http://www.iphonebackupextractor.com/ and found what I was looking for.
Also it seems like I just had to change the lockscreen in the iPhone since the file called LockScreen.jpg was the picture I was looking for but since I had another lockscreen using winterboard I didnt think of this.
Good luck to anyone else who has problems similar to this.