Search Unity

Mac App Store - Receipt Validation Plugin - Enjoy :-)

Discussion in 'Assets and Asset Store' started by seon, Feb 5, 2011.

  1. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    We (Sector3) have decided to release a binary version of our receipt validation plugin for the Mac App Store to the community.

    It's for Unity Pro users only and it's very basic and very easy to use.

    1. Unzip the attachment into your plugins folder
    2. Use the following line of code in your game in the Awake() function of the first script that runs.

    Code (csharp):
    1. ReceiptVerifier.ValidateReceiptInsideBundle();
    And that's it.

    The plugin will check for a valid receipt for the app and if it doesn't find one, BANG... it exits the app with a code 173.

    As I said above, it's very basic and does all that is needed to validate an App.

    We hope everyone finds it useful :)
     

    Attached Files:

  2. Martin-Schultz

    Martin-Schultz

    Joined:
    Jan 10, 2006
    Posts:
    1,377
    Mega awesome, thanks a lot for sharing!
     
  3. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058


    Let's all pitch in and buy Seon a case of his national beverage.

    Thank's Seon!
     
  4. Yorick2

    Yorick2

    Joined:
    Jan 24, 2009
    Posts:
    297
    Thanks!
     
  5. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    No need for thanks... we are happy to help other community members out. Sorry we didn't post it earlier.
     
    Last edited: Feb 5, 2011
  6. Yorick2

    Yorick2

    Joined:
    Jan 24, 2009
    Posts:
    297
    Is it supposed to go BANG on the Editor too? :)
     
  7. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    Yes it will if you are not familiar with how to code around editor usage... try

    Code (csharp):
    1. #if !UNITY_EDITOR
    2.      ReceiptVerifier.ValidateReceiptInsideBundle();
    3. #endif
     
  8. Yorick2

    Yorick2

    Joined:
    Jan 24, 2009
    Posts:
    297
    Yes, I figured it out. I didn't know if it worked or crashed the first time. :)
    But I tried to run the app after building and it quit and showed me the login screen... so it definitely works.

    Waiting for review now... thanks again!
     
  9. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    Glad you got it integrated and have your game submitted!
     
  10. scinfu

    scinfu

    Joined:
    Oct 23, 2008
    Posts:
    404
    Thank you !!!!
     
  11. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    QUESTION.. What is the code you exit with?
    Doesn't apple say that you are not allowed to quit an app via code but that the only way to end an app is to launch another one in it's place or to press the Home button? Haven't been keeping up to date so this might have changed, but isn't that the case?

    or are you working on the principle that Apple will never know because they will be running the valid copy and those who aren't won't be able to complain about it? :p
     
  12. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    Home button? I am confused. This is for OSX Apps on the Mac App Store.

    Apple's requirement is that your Mac application exits with a 173 code, which 10.6.6 understands as a call to prompt the Mac App Store login prompt.
     
  13. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    My bad... sorry, confused there. I saw "App" and read it as "iPhone"...
    My bad :)
    Thanks for clearing that up :)
     
  14. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    Does one need this for Mac App Store apps? (Sorry i don't know much about it ;))
     
  15. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    Only if you want Apple's DRM. It's not a requirement.
     
  16. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Thanks a lot for saving me a few hours today Seon!
     
  17. Martin-Schultz

    Martin-Schultz

    Joined:
    Jan 10, 2006
    Posts:
    1,377
    Important note: Don't move the ReceiptVerifierBundle.bundle in a subfolder within the Plugins folder, won't work then!
     
  18. Martin-Schultz

    Martin-Schultz

    Joined:
    Jan 10, 2006
    Posts:
    1,377
    Just in case anyone else got a rejection mail from Apple like this:

    It is because the plugin is compiled as fat plugin supporting multiple architectures and Apple seems suddenly to only allow x64 and i386 architectures anymore also for the plugins. Seon would need to recompile his plugin and post it here. I just wanted to post this if others stumble too upon this rejection and wondered what is going on. A few weeks ago it was possible to submit with Seons version above. Weird.

    You can check that with the lipo command:

    That is my game bundle:

    Hard Rock Racing.app/Contents/Plugins/ReceiptVerifierBundle.bundle/Contents/MacOS

    lipo -info ReceiptVerifierBundle
    Architectures in the fat file: ReceiptVerifierBundle are: x86_64 i386 ppc7400

    That ppc is the one Apple mourns about.
     
  19. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Seems bit like supporting a 486 if we're going to support powerpc still :p
     
  20. Martin-Schultz

    Martin-Schultz

    Joined:
    Jan 10, 2006
    Posts:
    1,377
  21. JakeT

    JakeT

    Joined:
    Nov 14, 2010
    Posts:
    34
    Seon - thank for the resource! Is there any way to test this locally? I installed the plugin, but when I run on my own test machine, it closes. I'm guessing it has something to do with the cert or provisioning profile? I've got my cert installed correctly, but haven't figured out how to install my Mac Provisioning Profile (dragging it into XCode Organizer doesn't seem to work). Should it quit on a dev machine?
     
  22. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    Hey JakeT,

    There is really no testing required. It will ALWAYS fail if it doesn't come from the App Store (which is the whole point) :)

    Don't call the code from your project (comment out) if you need to run the app on your machine to test your game, when you are ready for release, call the verifier (un-comment) and it should drop out as you see, but if you are running 10.6.7 or above, when the app drops out (as it should do if it not the paid version) it should bring up the AppStore login panel instead.

    Unfortunately there is no easy way to test locally with Apple's verification, as you need to build the plugin with the test receipt Apple provide OR have it run off the real one, and I could never get it to store the test one in the plugin and have 2 functions, one for test and one for real, so I just scrapped local testing.

    All of this btw has nothing to do with signing or packaging. The verification will ALWAYS fail if active and it's not a Real App Store version.

    Cheers :)
     
  23. JakeT

    JakeT

    Joined:
    Nov 14, 2010
    Posts:
    34
    Seon - So then it's working like a charm. Will let you know if I run into any problems on submission. Thanks a ton!
     
  24. mehware

    mehware

    Joined:
    Nov 19, 2007
    Posts:
    739
    Does Unity's 3.4 "UseMac App Store receipt validation" check box in player settings take place of this?
     
  25. Martin-Schultz

    Martin-Schultz

    Joined:
    Jan 10, 2006
    Posts:
    1,377
  26. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    116
    sorry to be digging up an old thread but can I assume that the message I get when the app exits with 173...

    “” is damaged and can’t be opened. Delete “” and download it again from the App Store.

    Is this as expected? The app is within iTunes Connect but i've yet to upload a Binary so I'm not quite sure where this page would lead if it didn't show this message...?