简体   繁体   中英

Free & premium game with both same NSUserdefaults

I Want to publish 2 versions of my game, 1 for free with advertisement and 1 premium.

But if the user is in level 9 in the free version and it buys the premium, than it should begin from level 9 in the premium version.

How do I do this?

You can take advantage of the ability to share NSUserDefaults suites between applications.

[[NSUserDefaults alloc] initWithSuiteName:@"yourGroupIdentifier"];

To enable your apps for this functionality you need to enable App Groups in your targets:

  • Select the project file in the Xcode Project Navigator
  • Select your target
  • Select the tab Capabilities
  • Enable App Groups and give it a name ("yourGroupIdentifier")

Initialising NSUserDefaults as shown above in both your apps will enable you to read and write the same defaults from both apps.

Having said that, I would suggest to use an In-App Purchase to unlock the pro version, instead of having 2 different products; for a better user experience.

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