0

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?

Victor Engel
  • 2,037
  • 2
  • 25
  • 46

1 Answers1

0

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

Jojodmo
  • 23,357
  • 13
  • 65
  • 107
  • So in other words, the user will know when the purchase was acknowledged but not when the download completed. They will know eventually, when the content shows up in the app. Is that about right? – Victor Engel Nov 04 '13 at 04:59
  • If you have nothing extra, They will not know when it is completed. Check in my updated code to find out how to alert them when it is complete. @VictorEngel – Jojodmo Nov 04 '13 at 15:19
  • Thanks. Apparently invalidate is not valid, ironically. :) – Victor Engel Nov 04 '13 at 17:05
  • Haha, wow, use `purchasingProductAlert = nil` instead then :D – Jojodmo Nov 04 '13 at 23:21
  • Actually, there's a method for this: `-dismissWithClickedButtonIndex: animated:`, which is what I used. Must set a property, of course, so you have something to send the message to. Then nil the property after dismissing. – Victor Engel Nov 04 '13 at 23:24
  • @VictorEngel This would be a better way to dismiss it, I agree. – Jojodmo Nov 04 '13 at 23:58