iOS App Persistent Settings After App Deleted

2019-04-10 17:20发布

问题:

We are creating an app as follows:

  • User starts with 2 free "tokens"
  • User can buy a pack of 10 tokens with $.99 in-app purchase

We have implemented this using NSUserDefaults to save the number of tokens.

Is there a way to make our free 2 token setting persistent? Even if they delete the app? Right now you can delete the app and reinstall to get 2 tokens again. iOS 5 has NSUbiquitousKeyValueStore for saving settings to iCloud, is that any better?

If not we will have to use a web service for this...

NOTE: This app is in MonoTouch, but probably irrelevant to the question. Also, in our app, the user wouldn't care to reinstall the app to get 2 more tokens (there is no other settings or game progress they would lose).

回答1:

Just my 2c as @Almo covers most of this already and should get the credits :-)

NSUbiquitousKeyValueStore has the advantage of being by-user, e.g. several devices would share the same free tokens. OTOH that might not be something you want in your app...

Leaving data after uninstallation goes against the sandboxing of applications. There are ways to do it, like you can add images/photos/contacts/..., but unlikely to be "Apple approved" and more than likely easy to hack around.

So I also suggest you to use a web service. A simple way would be to validate with the service (e.g. using the device's MAC address since the device unique identifier is going away) when no application data is found (install and re-install) if it's a know device (no token) or not (get tokens).

If the paid tokens are re-usable (could be re-played by re-installing a backup that includes them as data) then you might want to track them with the web service. Non-reusable tokens won't suffer from this (and are likely easier to deal with).



回答2:

You can set token to the Keychain. If the user uninstall app and install it again you can restore token from the Keychain.

sskeychain



回答3:

Even if you try to make the setting persistent, I don't think it would be that hard for them to find that and delete it as well during a reinstall. If you want to prevent just casual cheating, maybe that's fine. But if this is your revenue stream, I'd recommend using a webservice.

Edited to add: I don't have any experience with iCloud. That might make sense, too.