0

In my iOS nativescript app, I want users to be able to upload files to iCloud and also retrieve them from iCloud. So it would work like other apps, such as photos, where you can save your photos and retrieve them from iCloud.

The goal is to remove stress on phone storage.

Is this possible?

I earlier asked a question regarding backing up all app data to iCloud (link). It looks like this is possible--users can add the app to an iCloud backup. But this is different than what I am asking here. In that case, a user would have to retrieve all of their phone's data from the backup.

Here, I am looking for a way for users to (1) upload just specific types of files (say, pdf files or media files) to iCloud that they could later (2) download into the app itself.

In other words, they could choose to save and access files using iCloud instead of storing them locally on their phones.

I have seen this question asked earlier on nativescript forums and stackoverflow, but without answers.

So any help is appreciated.

SeanRtS
  • 1,005
  • 1
  • 13
  • 31
  • If you have enabled iCould capabilities for your app id then by default everything you put inside documents directory will be considered for backup. You will have to choose which one you don't want to back up with [NSURLIsExcludedFromBackupKey](https://developer.apple.com/library/archive/qa/qa1719/_index.html) flag. – Manoj Dec 01 '18 at 17:32
  • Thank you, but I am not talking about a backup. I want users to store the files on icloud (not the app at all). Just like, for example, photos: here, you take a photo, and it is saved automatically onto the icloud. You can then download photos from icloud into your photo app. Is this possible for files on a nativescript app? – SeanRtS Dec 01 '18 at 17:48
  • I am thinking through what you mean by "put inside documents directory". Let's say I have pdf files the users will create. Do you mean that I can identify these types of files "in the documents directory", and then these files will be automatically uploaded to icloud when user creates them? And then when the user opens the app these files will be automatically downloaded from icloud into the app? – SeanRtS Dec 01 '18 at 18:18
  • Yes, that's correct. Every file saved in the documents directory will be counted for iCould sync. You don't have to manually handle them. Set NSURLIsExcludedFromBackupKey on specific files / folders which you don't want to be synced. More info can be found from the link in my previous comment. – Manoj Dec 02 '18 at 08:11
  • Thank you. Sounds very promising. I will look into it. – SeanRtS Dec 02 '18 at 19:06
  • Hi @Manoj, this is the thing I don't yet get: Goal: Have a backup of the app data saved to user's iCloud account. Question: Other than enabling Cloudkit in xcode (in the app id, provisioning profile, and xcode), is there further configuration I need to do? For example, setting up schemas? From your earlier notes, I thought iCloud would "just work" by default--and would automatically backup my app when I enabled it. But it seems others generally do have to go into some real backend configuration, like this guy: https://youtu.be/2Y45vk7d_Bg?t=825 . – SeanRtS Mar 06 '19 at 15:22

0 Answers0