In the WWDC 2013 talk on processing app store receipts, it is suggested that for iOS apps, receipt validation code should be called as soon as possible. Even before application:didFinishLaunchingWithOptions:
- i.e. in the main()
function. I suppose that the way this would work is as follows:
int main(int argc, char *argv[]) {
@autoreleasepool {
validateReceiptMethod(); // <---- HERE
int retVal = UIApplicationMain(argc, argv, nil, nil);
return retVal;
}
}
The idea is that the UIApplicationMain()
method is what launches your app and calls application:didFinishLaunchingWithOptions:
. If you put the validateReceiptMethod()
after UIApplciationMain()
, it would never run.
Anyway, this is working great. But what if there is no receipt? Then you need to call SKReceiptRefreshRequest
to get a new one from the app store, which is fine. But if you run this code before UIApplciationMain()
, it will also run before any of your UI is displayed. So what would happen in terms of showing the user the apple ID login dialog? Is it even possible to call SKReceiptRefreshRequest
from the main()
method?