How can I link iCloud account with server account?
You don't. There's no public API that can link your server to iCloud and access the user's files. iCloud is not a web service, it's a system for syncing files and other data among different iOS devices used by the same person.
How to handle when user changes his iCloud account in the device but uses old server account.
In the app you can get a unique identifier for the iCloud account by calling [[NSFileManager defaultManager] ubiquityIdentityToken]
. You can save the value, and later check to see if the current value matches the old one. If they're different, the user has changed accounts. There's also a notification called NSUbiquityIdentityDidChangeNotification
that tells you if the account changes while the app is running.
This identifier will be different on different devices, even for the same iCloud account. It's not useful except on the device where you obtain its value.
How to handle when user don't agree to save the video files in iCloud?
Then... don't save them there. Your only other options are to save the videos on the user's device, or to upload them to a server somewhere. If your server can't handle them, you'll need to find a different one.
How to handle when iCloud account runs out of memory.
You won't be able to save any more files in the user's iCloud account. Your only real option is to ask them to delete some previous data to make space.