Class: MotionPaddle
- Inherits:
-
Object
- Object
- MotionPaddle
- Defined in:
- lib/motion-paddle/paddle_setup.rb
Class Method Summary collapse
-
.activated(note) ⇒ Object
internal.
- .activated? ⇒ Boolean
- .activated_email ⇒ Object
- .activated_licence_code ⇒ Object (also: activated_license_code)
- .api_key ⇒ Object
-
.call_listeners(name, *args) ⇒ Object
internal.
- .can_force_exit=(can_force_exit) ⇒ Object
- .can_force_exit? ⇒ Boolean
-
.continue(note) ⇒ Object
internal.
- .currency ⇒ Object
- .current_price ⇒ Object
- .deactivate_licence ⇒ Object (also: deactivate_license)
- .dev_name ⇒ Object
- .enabled? ⇒ Boolean
- .enabled_paddle_store? ⇒ Boolean
- .has_tracking_started=(has_tracking_started) ⇒ Object
- .has_tracking_started? ⇒ Boolean
- .image ⇒ Object
-
.licenceDeactivated(deactivated, message: deactivateMessage) ⇒ Object
internal.
- .listen(*names, &block) ⇒ Object
- .mas_store? ⇒ Boolean
- .paddle_instance ⇒ Object
- .paddle_store? ⇒ Boolean
-
.paddleDidFailWithError(error) ⇒ Object
internal.
-
.plist ⇒ Object
internal.
- .product_id ⇒ Object
- .product_image ⇒ Object
- .product_name ⇒ Object
- .psk_instance ⇒ Object
- .psk_purchase_product(product_id, &block) ⇒ Object
- .psk_receipt_for_product_id(product_id) ⇒ Object
- .psk_show(product_ids = nil, &block) ⇒ Object
- .psk_show_product(product_id, &block) ⇒ Object
- .psk_valid_receipts ⇒ Object
-
.PSKDidCancel ⇒ Object
internal.
-
.PSKDidFailWithError(error) ⇒ Object
internal.
-
.PSKProductPurchased(transactionReceipt) ⇒ Object
internal.
- .setup(window = nil, &block) ⇒ Object
- .show_licencing ⇒ Object (also: show_licensing)
- .store ⇒ Object
- .time_trial=(time_trial) ⇒ Object
- .time_trial? ⇒ Boolean
- .trial_days_left ⇒ Object
- .trial_duration ⇒ Object
- .trial_text ⇒ Object
- .vendor_id ⇒ Object
- .will_continue_at_trial_end=(will_continue_at_trial_end) ⇒ Object
- .will_continue_at_trial_end? ⇒ Boolean
- .will_show_activation_alert=(will_show_activation_alert) ⇒ Object
- .will_show_activation_alert? ⇒ Boolean
- .will_show_licensing_window=(will_show_licensing_window) ⇒ Object
- .will_show_licensing_window? ⇒ Boolean
- .will_simplify_views=(will_simplify_views) ⇒ Object
- .will_simplify_views? ⇒ Boolean
Class Method Details
.activated(note) ⇒ Object
internal
248 249 250 |
# File 'lib/motion-paddle/paddle_setup.rb', line 248 def activated(note) call_listeners :activated, note end |
.activated? ⇒ Boolean
201 202 203 |
# File 'lib/motion-paddle/paddle_setup.rb', line 201 def activated? enabled_paddle_store? && paddle_instance.productActivated end |
.activated_email ⇒ Object
217 218 219 |
# File 'lib/motion-paddle/paddle_setup.rb', line 217 def activated_email enabled_paddle_store? && paddle_instance.activatedEmail end |
.activated_licence_code ⇒ Object Also known as: activated_license_code
211 212 213 |
# File 'lib/motion-paddle/paddle_setup.rb', line 211 def activated_licence_code enabled_paddle_store? && paddle_instance.activatedLicenceCode end |
.api_key ⇒ Object
31 32 33 |
# File 'lib/motion-paddle/paddle_setup.rb', line 31 def api_key self.plist['api_key'] end |
.call_listeners(name, *args) ⇒ Object
internal
242 243 244 245 |
# File 'lib/motion-paddle/paddle_setup.rb', line 242 def call_listeners(name, *args) @listeners ||= {} @listeners[name.to_sym].each { |block| block.call(name.to_sym, *args) } if @listeners.has_key?(name.to_sym) end |
.can_force_exit=(can_force_exit) ⇒ Object
81 82 83 |
# File 'lib/motion-paddle/paddle_setup.rb', line 81 def can_force_exit=(can_force_exit) enabled_paddle_store? && paddle_instance.setCanForceExit(can_force_exit) end |
.can_force_exit? ⇒ Boolean
77 78 79 |
# File 'lib/motion-paddle/paddle_setup.rb', line 77 def can_force_exit? enabled_paddle_store? && paddle_instance.canForceExit end |
.continue(note) ⇒ Object
internal
253 254 255 |
# File 'lib/motion-paddle/paddle_setup.rb', line 253 def continue(note) call_listeners :continue, note end |
.currency ⇒ Object
43 44 45 |
# File 'lib/motion-paddle/paddle_setup.rb', line 43 def currency self.plist['currency'] end |
.current_price ⇒ Object
35 36 37 |
# File 'lib/motion-paddle/paddle_setup.rb', line 35 def current_price self.plist['current_price'] end |
.deactivate_licence ⇒ Object Also known as: deactivate_license
221 222 223 |
# File 'lib/motion-paddle/paddle_setup.rb', line 221 def deactivate_licence enabled_paddle_store? && paddle_instance.deactivateLicence end |
.dev_name ⇒ Object
39 40 41 |
# File 'lib/motion-paddle/paddle_setup.rb', line 39 def dev_name self.plist['dev_name'] end |
.enabled? ⇒ Boolean
3 4 5 |
# File 'lib/motion-paddle/paddle_setup.rb', line 3 def enabled? (NSClassFromString('Paddle') != nil) end |
.enabled_paddle_store? ⇒ Boolean
7 8 9 |
# File 'lib/motion-paddle/paddle_setup.rb', line 7 def enabled_paddle_store? enabled? && paddle_store? end |
.has_tracking_started=(has_tracking_started) ⇒ Object
97 98 99 |
# File 'lib/motion-paddle/paddle_setup.rb', line 97 def has_tracking_started=(has_tracking_started) enabled_paddle_store? && paddle_instance.setHasTrackingStarted(has_tracking_started) end |
.has_tracking_started? ⇒ Boolean
93 94 95 |
# File 'lib/motion-paddle/paddle_setup.rb', line 93 def has_tracking_started? enabled_paddle_store? && paddle_instance.hasTrackingStarted end |
.image ⇒ Object
47 48 49 |
# File 'lib/motion-paddle/paddle_setup.rb', line 47 def image self.plist['image'] end |
.licenceDeactivated(deactivated, message: deactivateMessage) ⇒ Object
internal
258 259 260 |
# File 'lib/motion-paddle/paddle_setup.rb', line 258 def licenceDeactivated(deactivated, message: deactivateMessage) call_listeners :deactivated, deactivated, deactivateMessage end |
.listen(*names, &block) ⇒ Object
160 161 162 163 164 165 166 167 |
# File 'lib/motion-paddle/paddle_setup.rb', line 160 def listen(*names, &block) return if block.nil? @listeners ||= {} names.each { |name| @listeners[name.to_sym] ||= [] @listeners[name.to_sym] << block } end |
.mas_store? ⇒ Boolean
231 232 233 |
# File 'lib/motion-paddle/paddle_setup.rb', line 231 def mas_store? self.plist['store'] == 'mas' end |
.paddle_instance ⇒ Object
11 12 13 |
# File 'lib/motion-paddle/paddle_setup.rb', line 11 def paddle_instance enabled? && Paddle.sharedInstance end |
.paddle_store? ⇒ Boolean
227 228 229 |
# File 'lib/motion-paddle/paddle_setup.rb', line 227 def paddle_store? self.plist['store'] == 'paddle' end |
.paddleDidFailWithError(error) ⇒ Object
internal
263 264 265 |
# File 'lib/motion-paddle/paddle_setup.rb', line 263 def paddleDidFailWithError(error) call_listeners :error, error end |
.plist ⇒ Object
internal
236 237 238 239 |
# File 'lib/motion-paddle/paddle_setup.rb', line 236 def plist (@plist = NSBundle.mainBundle.objectForInfoDictionaryKey("MotionPaddle_#{NSBundle.mainBundle.infoDictionary['CFBundleShortVersionString']}")) && (@plist = @plist.first) unless @plist @plist end |
.product_id ⇒ Object
23 24 25 |
# File 'lib/motion-paddle/paddle_setup.rb', line 23 def product_id self.plist['product_id'] end |
.product_image ⇒ Object
63 64 65 |
# File 'lib/motion-paddle/paddle_setup.rb', line 63 def product_image self.plist['product_image'] end |
.product_name ⇒ Object
51 52 53 |
# File 'lib/motion-paddle/paddle_setup.rb', line 51 def product_name self.plist['product_name'] end |
.psk_instance ⇒ Object
15 16 17 |
# File 'lib/motion-paddle/paddle_setup.rb', line 15 def psk_instance enabled? && PaddleStoreKit.sharedInstance end |
.psk_purchase_product(product_id, &block) ⇒ Object
189 190 191 192 193 194 195 |
# File 'lib/motion-paddle/paddle_setup.rb', line 189 def psk_purchase_product(product_id, &block) return unless enabled_paddle_store? psk = psk_instance psk.setDelegate(self) psk.purchaseProduct(product_id) listen(:psk_purchase, &block) end |
.psk_receipt_for_product_id(product_id) ⇒ Object
129 130 131 |
# File 'lib/motion-paddle/paddle_setup.rb', line 129 def psk_receipt_for_product_id(product_id) enabled_paddle_store? && psk_instance.receiptForProductId(product_id) end |
.psk_show(product_ids = nil, &block) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/motion-paddle/paddle_setup.rb', line 169 def psk_show(product_ids = nil, &block) return unless enabled_paddle_store? psk = psk_instance psk.setDelegate(self) if product_ids && !product_ids.empty? psk.showStoreViewForProductIds(product_ids) else psk.showStoreView end listen(:psk_purchase, &block) end |
.psk_show_product(product_id, &block) ⇒ Object
181 182 183 184 185 186 187 |
# File 'lib/motion-paddle/paddle_setup.rb', line 181 def psk_show_product(product_id, &block) return unless enabled_paddle_store? psk = psk_instance psk.setDelegate(self) psk.showProduct(product_id) listen(:psk_purchase, &block) end |
.psk_valid_receipts ⇒ Object
125 126 127 |
# File 'lib/motion-paddle/paddle_setup.rb', line 125 def psk_valid_receipts enabled_paddle_store? && psk_instance.validReceipts end |
.PSKDidCancel ⇒ Object
internal
278 279 280 |
# File 'lib/motion-paddle/paddle_setup.rb', line 278 def PSKDidCancel call_listeners :psk_cancel end |
.PSKDidFailWithError(error) ⇒ Object
internal
273 274 275 |
# File 'lib/motion-paddle/paddle_setup.rb', line 273 def PSKDidFailWithError(error) call_listeners :psk_error, error end |
.PSKProductPurchased(transactionReceipt) ⇒ Object
internal
268 269 270 |
# File 'lib/motion-paddle/paddle_setup.rb', line 268 def PSKProductPurchased(transactionReceipt) call_listeners :psk_purchase, transactionReceipt end |
.setup(window = nil, &block) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/motion-paddle/paddle_setup.rb', line 133 def setup(window = nil, &block) return unless enabled? return unless self.plist paddle = paddle_instance paddle.setProductId(product_id) paddle.setVendorId(vendor_id) paddle.setApiKey(api_key) if paddle_store? product_info = {KPADCurrentPrice => current_price, KPADDevName => dev_name, KPADCurrency => currency, KPADImage => image, KPADTrialText => trial_text, KPADProductName => product_name, KPADProductImage => product_image } if time_trial? product_info.merge!({KPADTrialDuration => trial_duration}) end paddle.startLicensing(product_info, timeTrial: time_trial?, withWindow: window) NSNotificationCenter.defaultCenter.addObserver(self, selector: 'activated:', name: KPADActivated, object: nil) NSNotificationCenter.defaultCenter.addObserver(self, selector: 'continue:', name: KPADContinue, object: nil) paddle.setDelegate(self) # block.call unless block.nil? listen(:activated, :continue, &block) end end |
.show_licencing ⇒ Object Also known as: show_licensing
205 206 207 |
# File 'lib/motion-paddle/paddle_setup.rb', line 205 def show_licencing enabled_paddle_store? && paddle_instance.showLicencing end |
.store ⇒ Object
19 20 21 |
# File 'lib/motion-paddle/paddle_setup.rb', line 19 def store self.plist['store'] || 'paddle' end |
.time_trial=(time_trial) ⇒ Object
72 73 74 75 |
# File 'lib/motion-paddle/paddle_setup.rb', line 72 def time_trial=(time_trial) paddle_instance.setIsTimeTrial(time_trial) if enabled_paddle_store? @time_trial = time_trial end |
.time_trial? ⇒ Boolean
67 68 69 70 |
# File 'lib/motion-paddle/paddle_setup.rb', line 67 def time_trial? @time_trial = self.plist['time_trial'] && self.plist['time_trial'] != 0 && self.plist['time_trial'] != '0' if @time_trial.nil? @time_trial end |
.trial_days_left ⇒ Object
197 198 199 |
# File 'lib/motion-paddle/paddle_setup.rb', line 197 def trial_days_left enabled_paddle_store? && paddle_instance.daysRemainingOnTrial end |
.trial_duration ⇒ Object
55 56 57 |
# File 'lib/motion-paddle/paddle_setup.rb', line 55 def trial_duration self.plist['trial_duration'] end |
.trial_text ⇒ Object
59 60 61 |
# File 'lib/motion-paddle/paddle_setup.rb', line 59 def trial_text self.plist['trial_text'] end |
.vendor_id ⇒ Object
27 28 29 |
# File 'lib/motion-paddle/paddle_setup.rb', line 27 def vendor_id self.plist['vendor_id'] end |
.will_continue_at_trial_end=(will_continue_at_trial_end) ⇒ Object
121 122 123 |
# File 'lib/motion-paddle/paddle_setup.rb', line 121 def will_continue_at_trial_end=(will_continue_at_trial_end) enabled_paddle_store? && paddle_instance.setWillContinueAtTrialEnd(will_continue_at_trial_end) end |
.will_continue_at_trial_end? ⇒ Boolean
117 118 119 |
# File 'lib/motion-paddle/paddle_setup.rb', line 117 def will_continue_at_trial_end? enabled_paddle_store? && paddle_instance.willContinueAtTrialEnd end |
.will_show_activation_alert=(will_show_activation_alert) ⇒ Object
113 114 115 |
# File 'lib/motion-paddle/paddle_setup.rb', line 113 def will_show_activation_alert=(will_show_activation_alert) enabled_paddle_store? && paddle_instance.setWillShowActivationAlert(will_show_activation_alert) end |
.will_show_activation_alert? ⇒ Boolean
109 110 111 |
# File 'lib/motion-paddle/paddle_setup.rb', line 109 def will_show_activation_alert? enabled_paddle_store? && paddle_instance.willShowActivationAlert end |
.will_show_licensing_window=(will_show_licensing_window) ⇒ Object
89 90 91 |
# File 'lib/motion-paddle/paddle_setup.rb', line 89 def will_show_licensing_window=(will_show_licensing_window) enabled_paddle_store? && paddle_instance.setWillShowLicensingWindow(will_show_licensing_window) end |
.will_show_licensing_window? ⇒ Boolean
85 86 87 |
# File 'lib/motion-paddle/paddle_setup.rb', line 85 def will_show_licensing_window? enabled_paddle_store? && paddle_instance.willShowLicensingWindow end |
.will_simplify_views=(will_simplify_views) ⇒ Object
105 106 107 |
# File 'lib/motion-paddle/paddle_setup.rb', line 105 def will_simplify_views=(will_simplify_views) enabled_paddle_store? && paddle_instance.setWillSimplifyViews(will_simplify_views) end |
.will_simplify_views? ⇒ Boolean
101 102 103 |
# File 'lib/motion-paddle/paddle_setup.rb', line 101 def will_simplify_views? enabled_paddle_store? && paddle_instance.willSimplifyViews end |