ProMotion-iap 0.2.1.beta1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04b7803087c35db767148574597a8ab7ab362330
4
- data.tar.gz: 6e75db90ae31c40bc2ba8559202e8e12c4ef8a75
3
+ metadata.gz: 21816a8d7a6a4ef77dcff985a2720d55563b5a1c
4
+ data.tar.gz: 837d821b6607553b86cfbf19aab11fcafb89acda
5
5
  SHA512:
6
- metadata.gz: 5f62e32f616300fcce8a2b39e40a74fcb7464af606eb950554f44c14adeb1fbd92f25386675d56de58dc19d28d78f6ca614c86f4c351e4c32285889d239ac0fd
7
- data.tar.gz: 64d667a643c98e2c8bb0b64dec33ab25e019edfcc2db8432def098d79e8dc61a1d7886a10bcabfc08eeb7a39d6bfa7295d8819e343cb22c793f49dd0bd6b9c22
6
+ metadata.gz: c203f8c34d6698514b6746baf426ca82961efc12fb47bb61ac15b343e72975840df067e7afcda51781038a836ed66d20837ffd7f97d6b127f77a3519601eab7d
7
+ data.tar.gz: acf138018aa2c1bbcc561edf55832a726171b6e5651dda3bca39b518b7ca1626fe158e36585a767eeb5c875b79b0450aba2785c97e054c1075d818fb0fb90b9b
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Build Status](https://travis-ci.org/clearsightstudio/ProMotion-iap.svg)](https://travis-ci.org/clearsightstudio/ProMotion-iap)
5
5
 
6
6
  ProMotion-iap is in-app purchase notification support for the
7
- popular RubyMotion gem [ProMotion](https://github.com/clearsightstudio/ProMotion).
7
+ popular RubyMotion gem [ProMotion](https://github.com/clearsightstudio/ProMotion). It also works as a stand-alone gem if you are not using ProMotion.
8
8
 
9
9
  ## Installation
10
10
 
@@ -4,9 +4,11 @@ unless defined?(Motion::Project::Config)
4
4
  raise "ProMotion-iap must be required within a RubyMotion project."
5
5
  end
6
6
 
7
- Motion::Project::App.pre_setup do |app|
7
+ Motion::Project::App.setup do |app|
8
8
  lib_dir_path = File.dirname(File.expand_path(__FILE__))
9
- app.files.unshift File.join(lib_dir_path, "ProMotion/product.rb")
10
- app.files.unshift File.join(lib_dir_path, "ProMotion/iap.rb")
9
+ app.files.unshift [
10
+ File.join(lib_dir_path, "ProMotion/iap.rb"),
11
+ File.join(lib_dir_path, "ProMotion/product.rb"),
12
+ ]
11
13
  app.frameworks << "StoreKit"
12
14
  end
@@ -47,8 +47,6 @@ module ProMotion
47
47
  @completion_handlers ||= {}
48
48
  end
49
49
 
50
- # private methods
51
-
52
50
  private
53
51
 
54
52
  def iap_setup
@@ -124,6 +122,12 @@ module ProMotion
124
122
  transaction.respond_to?(:payment) ? transaction.payment.productIdentifier : "all"
125
123
  end
126
124
 
125
+ def transaction_complete?(transactions)
126
+ states = transactions.map(&:transactionState)
127
+ return true unless states.include?(SKPaymentTransactionStatePurchasing)
128
+ false
129
+ end
130
+
127
131
  public
128
132
 
129
133
  # SKProductsRequestDelegate methods
@@ -162,6 +166,7 @@ module ProMotion
162
166
  end
163
167
  end
164
168
  end
169
+ iap_shutdown if transaction_complete?(transactions)
165
170
  end
166
171
 
167
172
  def paymentQueue(_, restoreCompletedTransactionsFailedWithError:error)
@@ -170,4 +175,4 @@ module ProMotion
170
175
 
171
176
  end
172
177
  end
173
- ::PM = ProMotion unless defined?(PM)
178
+ ::PM = ProMotion unless defined?(::PM)
@@ -1,6 +1,6 @@
1
1
  module ProMotion
2
2
  class IAP::Product
3
- include ProMotion::IAP
3
+ include PM::IAP
4
4
 
5
5
  attr_reader :product_id
6
6
 
@@ -20,9 +20,9 @@ module ProMotion
20
20
 
21
21
  def restore(&callback)
22
22
  restore_iaps(product_id) do |status, products|
23
- callback.call status, products.find{|p| p[:product_id] == product_id }
23
+ product = products.is_a?(Hash) ? products : products.find{|p| p[:product_id] == product_id }
24
+ callback.call status, product
24
25
  end
25
26
  end
26
27
  end
27
28
  end
28
- ::PM = ProMotion unless defined?(PM)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ProMotion-iap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1.beta1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamon Holmgren
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-01 00:00:00.000000000 Z
12
+ date: 2015-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: motion-stump
@@ -80,12 +80,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - ">"
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 1.3.1
85
+ version: '0'
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 2.4.6
88
+ rubygems_version: 2.4.5
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: Adds in-app purchase support to ProMotion.