简体   繁体   中英

Save my app data through phone restore - iOS Swift

What technology is available for me to save app data (Core Data) so that when a user switched phones and has a fresh phone they still have my app information?

I have heard people say cloudKit, however that seems overkill, I don't want the functionality to handoff between devices. I simply want the app data to be backed up when the user has iCloud backup enabled for the app.

If the answer is iCloud, what steps must I follow to enable such behavior? I have seen links to cloudKit tutorials, however all of them cover an extensive amount of material and work, and what I want to achieve seems simple enough. (As stated before I do not want handoff between devices, I have no need for it.).

Thank you for the suggestions

Edit: I have gone into "capabilities" and switched on iCloud. Now in my iPhone settings under iCloud backup my app appears. However does simply switching on iCloud capabilities persist your app data to iCloud Drive or backup?

Ex: Go to Settings -> Account -> iCloud -> Scroll down to iCloud Drive and ensure it is checked. My app shows there, but I haven't included any code to implement this (I simply flipped the switch in capabilities)

So from my current understanding I create Core Data as normal, however I add a listener for an changes/updates/deletes/creation of the persistentStore and upload/update iCloud via document storage when this happens? I was under the impression that iCloud was being depreciated and that only cloudKit will remain?

Edit 3:

iCloud = Depreciated, therefore the one and only solution available is cloudKit.

How does one implement cloudKit to interact correctly with Core Data?

What comes to mind is the following: - Enable cloudKit

  • Listen to all changes to persistent Store and reflect these changes in CloudKit (somehow)

  • On app start check to see if CloudKit matches core data (somehow)

  • if they are not the same then download cloudKit data and save to core data (somehow)

Please clarify if this is not the correct route to proceed down

What technology is available for me to save app data (Core Data) so that when a user switched phones and has a fresh phone they still have my app information?

There isn't any such problem. I've upgraded devices many times and nothing has ever been lost. When I got a new iPhone last year, and when I got a new iPad this year, all my apps on the new device simply showed up with the same settings and data as before on the old device.

That's the because the user who gets a new device backs up from the old device and restores to the new device. That's what I always do and it just works. You cannot reliably work around a user who is too stupid to know to do that, so I recommend not even thinking about it.

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