Keep files after uninstall

Is there a possibility to somehow keep some files on the device even if the user uninstalls the app? The reason I’m asking is if the user reinstalls the app, I’d like to access these files again.

Deleting an iOS app deletes the container that stores all of its local data, so I think that if you wanted to to this you’d have to achieve it with some kind of server-side storage that’s restored if the same user reinstalls and chooses to download their data again.

(I’ve got no idea whether the app you’re referring to has any kind of account management or server-side component, just trying to suggest a way around this)

2 Likes

I think they will remain if you store the required files in the Documents folder as opposed to ApplicationData.

1 Like

Xojo iOS apps cant access ‘the documents folder’ using vanilla Xojo.
The documents folder you get is local to the app, and deleted with the app.

It may be possible to get files into the area seen by ‘Files’ using declares
Some people have managed to get iCloud interaction working.
But anything in specialfolder.documents dies with the app.

1 Like

There are two ways of having persistent data, both can be used in combination.

  1. NSUbiquitousKeyValueStore
    This is similar to NSUserDefaults but data is saved on iCloud. It is limited to 1MB and will sync across devices using the same Apple ID.
    To enable it you must activate iCloud in the app’s profile and in Xojo > iOS > Capabilities > iCloud > Key Value storage

  2. Saving files on your own server.
    To retrieve the files set up a login+pwd for the user OR store a unique ID with NSUbiquitousKeyValueStore.

I can set up a demo on Github for NSUbiquitousKeyValueStore if you want to use it.

In my Secret Santa app I use both:
All secret Santa groups are stored on my own server with a unique user_uuid.
That user_uuid is stored on the device AND in NSUbiquitousKeyValueStore.

If the user installs the app on a second device using the same Apple ID, he will have access to the same Secret Santa groups.
If the user uninstalls the app then installs it back again, he will still have access to the data that was saved on my server, thanks to the uuid that is stored in NSUbiquitousKeyValueStore.

1 Like

Thank you, all! I am sorry, I did not mention that I had already tried with SpecialFolder.Documents and SpecialFolder.ApplicationSupport but the files there are getting deleted. I think NSUbiquitousKeyValueStore will work for me. Would appreciate if you could have some example to look at, Jeremie. Thanks a lot already!

2 Likes
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.