views:

154

answers:

1

I'm programming StoreKit into my iPhone app. I can't seem to be able to intercept the buy item dialog wait time either before or after pressing the button to purchase the item. Pretty much what I want is an indicator on the screen before the buy dialog appears and after, but before the purchased item is unlocked. I don't want my users being hung up on the screen, not knowing if their purchase went through.

Also, if I'm not displaying a store, just one predictable item, do I need to requestProductData? Anything to make the wait time as less as possible would be good.

One last thing: In the - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions method, if I show an alertView if the case SKPaymentTransactionStateFailed: is fulfilled, I keep on getting multiple calls, even if the purchase is done once.

Thanks!

Please help with anything you can (just trying to learn my iPhone programming).

+2  A: 

For your first question on an Activity View during the processing slow stretches.

You can intercept the "SKPaymentTransactionStatePurchasing state in the Payment Queue to put up an Alert View with an activity Indicator. Dismiss the View in the Purchased, Restored and Failed states after you have completed your processing. The StoreKit generated AlertViews will make this one disappear and re-appear as required throughout the process.

case SKPaymentTransactionStatePurchasing:
                purchaseActivityIndicator = [[UIAlertView alloc] initWithTitle:@"Processing purchase" message:@"Please wait..." delegate:self cancelButtonTitle:nil otherButtonTitles:nil,nil];
                UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
                [activity setFrame:CGRectMake(121.0f, 80.0f, 36.0f, 36.0f)];
                [purchaseActivityIndicator addSubview:activity];
                [activity startAnimating];
                [activity release];
                [purchaseActivityIndicator show];
                [purchaseActivityIndicator release];
                break;

For the 2nd question, I kickoff the load of my store items at app startup time so they are ready by the time the user gets to the store. Since they load async, they should be ready by the time a user get to a store view.

Not sure on the last question.

Steve

kjs
Works wonderfully! Thanks kjs.
John M. P. Knox