ProMotion-iap

ProMotion-iap is in-app purchase notification support for the popular RubyMotion gem ProMotion.

Installation

gem 'ProMotion-iap'

Usage

AppDelegate

Include PM::IAP to add some in-app purchase methods to a screen, app delegate, or other class.

# app/screens/purchase_screen.rb
class PurchaseScreen < PM::Screen
  include PM::IAP

  def on_load

    retrieve_iaps([ "productid1", "productid2" ]) do |products, error|
      # products looks something like the following
      [{
        product_id:               "productid1",
        title:                    "title",
        description:              "description",
        price:                    <BigDecimal 0.99>,
        formatted_price:          "$0.99",
        price_locale:             <NSLocale>,
        downloadable:             false,
        download_content_lengths: <?>, # TODO: ?
        download_content_version: <?>, # TODO: ?
        product:                  <SKProduct>
      }, {...}]
    end

    purchase_iap "productid" do |status, transaction|
      case status
      when :in_progress
        # Usually do nothing, maybe a spinner
      when :deferred
        # Waiting on a prompt to the user
      when :purchased
        # Notify the user, update any affected UI elements
      when :canceled
        # They just canceled, no big deal.
      when :error
        # Failed to purchase
        transaction.error.localizedDescription # => error message
      end
    end

    restore_iaps do |status, products|
      if status == :restored
        # Update your UI, notify the user
      end
    end


  end
end

purchase_iap(*product_ids, &callback)

TODO


Find the Product ID here:

product id

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Make some specs pass
  5. Push to the branch (git iap origin my-new-feature)
  6. Create new Pull Request