Question

I think I have the in-app purchase functionality for my app working now, except for a progress bar for downloads from Apple servers. I'm wondering now whether I should display a progress bar or not. What say you?

If I should display one, how should it be displayed? My products are presented using a table view controller, so I could put a progress bar on the table cell for that product, I guess. Or I could put up a progress bar in the app window.

The thing is, the IAP helper class is what subscribes to SKPaymentTransactionObserver notifications, but it doesn't have a UI. So if I put up a progress bar, what would be the best way to get the progress data? Should I make the VC a delegate of my IAP helper class? Should I make the VC an additional observer of SKPaymentTransactionObserver?

Was it helpful?

Solution

You should either have no progress bar, or, make another AlertView, when SKPaymentStatePurchasing then make a void:

- (void) purchasingProductAlertShow {

UIAlertView *purchasingProductAlert = [[UIAlertView alloc]

                         initWithTitle:@""
                         message:[NSString stringWithFormat:@"Loading..."]
                         delegate:nil
                         cancelButtonTitle:@""
                         otherButtonTitles:nil];

[purchasingProductAlert show];

}

or something like that, then, when SKPaymentStatePurchased do purchasingProductAlert = nil; You may want to make your own, custom Alert view for purchasing, though.

You could also alert them when the purchase is finished, You could do that like so: when SKPaymentStatePurchased make a void:

- (void) purchasedProductAlertShow {

UIAlertView *purchasedProductAlert = [[UIAlertView alloc]

                         initWithTitle:@"Complete!"
                         message:[NSString stringWithFormat:@"Your purchase is complete! You will now be able to enjoy no ads!"]
                         delegate:nil
                         cancelButtonTitle:@"Okay!"
                         otherButtonTitles:nil];

[purchasedProductAlert show];

}

for the message you would want to put whatever you want there, I'm using removing ads as an example. Then in SKPaymentStatePurchased do [self purchasedProductAlertShow] as well as any of your other code. This will make it so that when the user completes a purchase, it shows the alert purchasingProductAlert

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top