title: iOS 7 Local (on device) Receipt Validation and In-App Purchases Check
body: <p>I have implemented receipt validation locally on the device using OpenSSL and the asn1c compiler with help from Apple's Receipt Validation Programming Guide. My app only supports iOS 7 and up.</p>
  
  <p>As recommended by Apple I call, <code>[[NSBundle mainBundle] appStoreReceiptURL]</code> to get the app store receipt. I also do this when the app is 'first' launched before displaying any UI. This first launch call is needed as Apple recommends refreshing the receipt if its not there on first try. As a result of this call (<code>SKReceiptRefreshRequest</code>) the app asks the user to enter their iTunes log in information.</p>
  
  <p>Now the problem is Apple keeps rejecting the app saying I am making calls to their production servers instead of the sandbox servers. But that according to what I understand from the Receipt Validation Programming Guide is only valid if you use the second approach of validation and send data to Apple via your own secure server. I am however doing everything locally and am very confused about how to differentiate between the production and sandbox environments so that my app may pass review.</p>
  
  <p>Any pointers or suggestions would be very helpful.</p>