这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Canceling a purchase #13

@jayroh

Description

@jayroh

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
end

This 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions