Question

I have an app that has consumable IAP. It's an IAP that users consumes it over the time, something like the IAP has 100 points, while users may use 10 today and 50 tomorrow, so the user would have 100-10-50=40 points left for later use. The app gives out initial points of 100 to let users to try it out. I used UserDefaults to record that and it works fine, EXCEPT when user delete the app --- when I tested two methods: 1, delete and reinstall, I got the initial 100 points again; 2, I reset iPhone language and got the initial 100 points again. This means users wouldn't go thru too much trouble to get the initial 100 points, which would basically stop my IAP from selling.

I currently don't have an external server to record/verify IAP. I don't want a bullet-proof mechanism to prevent hack. All I want is something that can survive delete/reinstall. After reading stackoverflow pages and I learned that 1, keychain survive deletion/reinstall, 2, it's usually used for password, 3, some developers use it to store IAP flags (bought the IAP or not), but 4, I don't know if it's okay to store a NSNumber (the 40 points left over in the example above). I wonder if keychain would be suitable for my case.

If keychain is okay to store NSNumber, anyone has some code to share? Thanks.

Updates with Lockbox: why I got Apple Mach-O-Linker Error: Objc-class-ref in ViewController.o? Something related to ARC? I saw Granoff (Lockbox developer) said ARC has been taken care of automatically. What I did was add Lockbox.h and .m file into my project and import to my app. Then app doesn't run because of the error. However when I tried Lockbox provided sample project, it works. Any insight? Thanks.

Lockbox error I got:

    Undefined symbols for architecture i386:
    "_OBJC_CLASS_$_Lockbox", referenced from:
    objc-class-ref in ViewController.o
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

I added "Security" framework. After adding security framework, I copied both Lockbox.h and .m files into my app. In ViewController.m file where I plan to use lockbox methods, I added "#import "Lockbox.h"". I could run at this step, without error. I then added the following line: if ([Lockbox stringForKey:mylockboxstring] != nil) {} I got error shown above.

Was it helpful?

Solution

Yes.

Have a look at http://github.com/granoff/Lockbox. It's a class exactly for this, although you may have to either extend it to store NSNumbers or use one of the currently supported data types, like an NSString.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top