-
Notifications
You must be signed in to change notification settings - Fork 7
Canceling a purchase #13
Description
Hey everyone!
First off - excellent gem. So so so much cleaner and more sane than the generic StoreKit API. Awesome work :).
The issue at hand - I've set up a small IAP manager class to contain most of the logic. It contains the following:
class IAPManager
attr_reader :in_app_purchase_id
def initialize(in_app_purchase_id)
@in_app_purchase_id = in_app_purchase_id
end
def purchase
@purchaser = PM::IAP::Product.new(in_app_purchase_id)
@purchaser.purchase do |status, transaction|
case status
when :in_progress then show_spinner
when :deferred then hide_spinner
when :purchased then complete_transaction
when :canceled then go_away
when :error then error(transaction.error.localizedDescription)
end
end
end
def show_spinner
CCHUD.showWithStatus('Purchasing course')
end
def hide_spinner
CCHUD.dismiss
end
def complete_transaction
CCHUD.showSuccessWithStatus('Course purchased')
end
def error(message)
CCHUD.showErrorWithStatus(message)
end
def go_away
CCHUD.dismiss
end
endThis is all instantiated with a little IAPManager.new('my_iap_id').purchase. When I fire this up in the simulator, click the purchase button, and dismiss the IAP dialog by hitting "cancel" the app crashes.
The crash log looks like this:
After doing a little googling I found this - http://aplus.rs/2012/a-single-bug-in-my-storekit-code-that-lost-me-90-of-iap-sales/. And that looks quite a bit similar, no? I dug through the Promotion-iap source and see that there is a private iap_shutdown method. However, it is not used anywhere in the library. Is that intentional, or possibly an oversight? If that needs to be called somewhere - where would it be?
Thanks so much for your time!