Here's my problem :
When using storekit for in-app purchase, i'm displaying a "loading" view to tell the user to wait for a few seconds while the process is in progress; but let's say this same user, when the storekit ask him for his itunes account password, press the "cancel" button... How can i "catch" this event in order to hide the loading view?
I'm afraid it could be a cause of rejection for Apple since user's communication is pretty important.
Thanks for any tips开发者_JS百科!
Edit : I'm not in a transaction here; my first step is to restore completed transactions so the password prompt is trigger by this method :
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
Something similar was reported in the Apple dev forums.
What happens when user hits Cancel after asking to restore......
In their case, a copy-and-paste of a method from the documentation created a bug that apparently compiled without error.
// wrong, but compiles
- (void)paymentQueue:(SKPaymentQueue *)queuerestoreCompletedTransactionsFailedWithError:(NSError *)error
instead of
// correct
- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
If your observer method looks like the first one above, then you're probably not receiving the failure message for the restore operation.
Update:
In SDK documentation for SKPaymentTransactionObserver
, I see the restore failure method for OS 3.1 (2009-11-17) but 3.0 documentation (2009-05-01) doesn't seem to have it. Strange since the 3.1 doc states this observer method is "Available in iPhone OS 3.0 and later".
To be sure. I checked my copy of iPhoneOS3.0.sdk/System/Library/Frameworks/StoreKit.framework/Headers/SKPaymentQueue.h to make sure the restore failure observer method is there. (It is.)
If the user clicks the cancel button then request will fail - use a store observer like so...
MyStoreObserver *observer = [[MyStoreObserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];
And handle like this....
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
default:
break;
}
}
}
精彩评论