简体   繁体   中英

IOS temporarily save data during app background refresh

I am building an app where we can record videos but it requires recording certain events due to which the app is closed and when the app is opened again, all the data is lost. Tiktok is using a similar approach where they save the data temporarily on the device storage and shows an alert when the app is opened again. Cant find the solution of what they are using to save data temporarily on device. This is how they are doing it - tiktok method

The question isn't clear to me. But I assume that you want to record something and get back at the time of relaunching the application.

The best way you can do:

First, continue recording until app goes to the background

Second, in appDidEnterBackground

a) please save the file to a unique name in the document directory/temp directory with a unique name. The second one is the best place to do. Then save the filename to the userdefaults.

or

b) Instead of doing the file save, save the Data to the userdefaults.

Third, in didBecomeActive

a) For 2a, if there is a name, try to fetch the file from the directory.

b) For 2b, if there is data available in userdefaults, try to show an alert that there is something in the userdefaults.

You have thousands of answers in StackOverflow for all of those steps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM