Need to verify receipt for IAP?

Discussion in 'iOS Programming' started by ArtOfWarfare, Sep 8, 2011.

  1. ArtOfWarfare, Sep 8, 2011
    Last edited: Sep 8, 2011

    ArtOfWarfare macrumors G3


    Nov 26, 2007
    I've made an app with an IAP, but currently it does nothing with the receipt other than store it in NSUserDefaults.

    Correct me if I'm wrong, but the contents of NSUserDefaults can be manipulated on jailbroken iPhones, right? So, were my app to be installed on a jailbroken iPhone, they could put in a phony NSData object with the correct key in the NSUserDefaults, and my app wouldn't know the difference.

    So, I figure that in addition to checking that any data is stored with the key for the NSUserDefaults, I need to verify that the data is for a valid receipt.

    Apple's documentation on the subject may just have left more questions than answers... first, here's the documentation:

    My questions:
    1.) How do I encode with base64 encoder? I looked through the information on NSCoder and I didn't see anything about base64.
    2.) How do I create a JSON object?
    3.) How do I post it?
    4.) Where is Apple's response going to appear? Should establish a delegate and give it a method to handle Apple's response?

    ... maybe it'd be better if I just found documentation on using JSON on the iPhone... I suspect questions 2-4, if not 1, could be answered by it if it exists...
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    Those two questions are easily answered by google.

    If you don't know what base64 or JSON is, then try searching Wikipedia.
  3. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium

    These are the Base64 Classes you need (this isn't build in on iOS, but is on Mac OSX).
    Then you need to format the string to Base64 Encrypting with those classes. Play around a bit, and good luck.

Share This Page