I'm builing an iPhone app that should handle subscriptions through In App Purchase. When I get the receipt back from Apple in my app I want to save the receipt on my own server and on my server I also want to verify the receipt with the Apple server. It is very important that this connection to my server is made as this saves information about the user that will be needed later.
In my SKPaymentTransactionObserver I'm now trying call my server on SKPaymentTransactionStatePurchased. The problem is that on SKPaymentTransactionStatePurchased there seems to be a standard alert saying "Thank You" and that the purchase is completed. As it take some time for the app to contact my server this standard alert is shown before the call to my server is completed and what happens if the user quits the app here, he thinks that the purchase is finished as it said so? When should I contact my server? And if I want to show an alert for the user when the call to my server is completed when should I do that?
This is the code I'm using:
//This is called on "SKPaymentTransactionStatePurchased"
- (void) completeTransaction: (SKPaymentTransaction *)transaction
{
[self saveAndVerifyOnServer:transaction];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}