ALAssetURL unique even after SYNC ipad/iPhone with iTunes - ios5

The documentation describes it as 'persistent' (http://developer.apple.com/library/ios/documentation/AssetsLibrary/Reference/ALAssetRepresentation_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40009728-CH1-SW16) but does this mean persistent over a single sync, persistent until new photos are added, persistent until old photos are deleted, or what? If I build a database that associates photo elements in the Camera Roll/Photo Library to data in my application using their ALAssetRepresentation url's, will these associations continue to work forever, even if the photos are moved or renamed?
If Asset url are not unique after sync then what is the alternate solution for this as i need to identify assets uniquely even after sync.

In my experience, the URLs are persistent between syncs (starting in iOS 5). But once the device is restored from an iTunes backup or from iCloud, the assets will get new URLs. This also happened after the upgrade from iOS 5 to iOS 6.
The alternative would to generate an own ID/Checksum for every photo: e.g. take the filename, recording date and file size and generate an MD5 or SHA1 Hash from it.

Related

Syncing data to iPad from iPhone

I want to sync data between iPhone and iPad. I am using core data and save the data in Documents of Document Container. Since Documents is backed up by both iTunes and iCloud. Since iCloud is deprecated in latest version of Xcode. Do I have to do anything else to sync data between these iOS devices?
Backups are not a sync mechanism. For one thing, backups are device specific. Data that gets backed up from someone's iPhone is not available to their iPad. There is no device-to-device data mixing through backups.
Putting the persistent store file in iCloud (via the iCloud file API) is not workable either. You can't just read/write the file in iCloud directly, you need to download the file first and later upload changes. Core Data isn't designed to work in that scenario. You might write code to do it, but the data would become corrupted almost immediately because Core Data isn't expecting you to mess with the persistent store like that.
If you want to sync data between devices, there are many options. Apple offers CloudKit, which is free and supported by Apple. Firebase is popular. Parse servers are still extremely common even though Parse itself is shutting down. Add to that Microsoft Azure and many, many others.

How can I store image to iCloud from my iphone application?

I got a project like MyPhoto Pro app in iPhone App Store (website).
Please, can any one help or guide me what are the technologies and frameworks i should use for developing?
But my primary things is that image should stored in iCloud.
For iCloud file storage see Designing for Documents in iCloud in docs.
Then check NSFileManager class, section Managing ICloud-Based Items.
-ubiquityIdentityToken – detect iCloud availability
-URLForUbiquityContainerIdentifier: – obtain URL for iCloud directory (container)
-setUbiquitous:itemAtURL:destinationURL:error: – move any local file to iCloud (or vice versa); one URL must be local and one must point into one of the iCloud containers
-startDownloadingUbiquitousItemAtURL:error: – download the file content
-evictUbiquitousItemAtURL:error: – delete iCloud file.
Also check NSMetadataQuery and NSMetadataItem classes used to discover new iCloud files. iCloud will automatically give you only metadata of the file, but content must be downloaded explicitely (see the methods above)

What happens to the content in my app after i upgrade/update the version in iPad/iPhone

I am storing a lot of images, books, audios etc of my app in
Documents Directory/Library/caches folder.
What happens to all the content if the user updates the version of the app from the app store or from iTunes. Will all of them get erased or will they be untouched during the app updating process?
They will be untouched during the upgrade process. I would like to note however that the Caches folder is meant to be used for data that is just cached rather than data you expect to always be available. The OS reserves the right to get rid of anything in the caches folder. If you're asking this question then I assume you want the data to be persistent so you should be aware that since iOS 5, Apple specifically state that data in the caches directory can be deleted at any time (apart from whilst your app is running).
They are supposed to remain untouched. There are a lot of existing examples for this behavior - try checking any photo sharing application or games that download levels in-game.

iPhone when does data get restored from backup

When does data get restored for an app? What if I save data in the app's document directory. Then they sync with iTunes. Now iTunes has a backup. Will that data be populated to another device when they sync that new device to their iTunes or will they just get a clean install of my app? I'm trying to figure out how to keep track of a subscription in app purchase and was wondering if I could keep record in NSUserDefaults or some other local store.
Backups are per-device. So a backup of your iPod will not be restored to your iPhone. In other words, there is no sync.
Many times iTunes fails to create complete backup of all the iPhone data say it be contacts, message, mails etc. This type of problem may occur due to not installing iTunes properly. So, you should check whether iTunes have been installed correctly or not. In case there is no problem with iTunes then it is possible that you are trying to create backup of the files which can not be backed with the help of iTunes. To overcome with this issue you need to make use of iPhone backup application. By using this tool you will be able to prepare backup of all the files within minutes safely.
If the user backs up to iTunes, and then restores their backup to another device (maybe they lost their original iPhone), the contents of the app Documents directory will be put on the new device. Anything in the tmp folder won't be backed up or restored like this, but the Documents folder will.
However, that's not the best way to store the in-app purchase information. You should be storing that on your own server and keeping a count of the number of times the purchased content has been used. Inform the user that they can use it a certain number of times (say three) and after that they will have to buy it again. I'm not exactly sure of any details beyond that (like how to verify their identity) but it should get you started.

iPhone, Where do I have to save user generated files if I want them to stay there after an app Upgrade (new release)? is Documents directory good?

I have an app that lets user record their own audio.
By now I'm saving those files into Documents directory.
My question is: if I will release a new version of that app, will user recorded files get deleted?
Is there a better place to store user generated audio files?
Should I use NSUserDefaults for data that stay even after app upgrade?
thx
NSUserDefaults is used for storing settings (objects of Key-Value Coding compliant classes)
Other data such files you should store in Documents folder, wich survive between updates (if you don't delete it yourself, of course :)
Both the Documents directory and NSUserDefaults survive application updates. Choosing which to use depends on the kind of your data.
if I will release a new version of that app, will user recorded files get deleted?
No.
Is there a better place to store user generated audio files?
No.
Should I use NSUserDefaults for data that stay even after app upgrade?
Only if your data is small.