@purchasely/cordova-plugin-purchasely 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,12 +12,13 @@
12
12
  @implementation CDVPurchasely
13
13
 
14
14
  - (void)startWithAPIKey:(CDVInvokedUrlCommand*)command {
15
- NSString *apiKey = [command argumentAtIndex:0];
16
- NSString *userId = [command argumentAtIndex:2];
17
- NSInteger logLevel = [[command argumentAtIndex:3] intValue];
18
- NSInteger runningMode = [[command argumentAtIndex:4] intValue];
15
+ NSString *apiKey = [command argumentAtIndex:0];
16
+ NSString *userId = [command argumentAtIndex:2];
17
+ NSInteger logLevel = [[command argumentAtIndex:3] intValue];
18
+ NSInteger runningMode = [[command argumentAtIndex:4] intValue];
19
+ NSString *sdkBridgeVersion = [command argumentAtIndex:5];
19
20
 
20
- [Purchasely setAppTechnology:PLYAppTechnologyCordova];
21
+ [Purchasely setAppTechnology:PLYAppTechnologyCordova];
21
22
  [Purchasely startWithAPIKey:apiKey appUserId:userId runningMode:runningMode eventDelegate:nil uiDelegate:nil paywallActionsInterceptor:nil logLevel:logLevel initialized:^(BOOL initialized, NSError * _Nullable error) {
22
23
  if (error != nil) {
23
24
  [self failureFor:command resultString: error.localizedDescription];
@@ -28,50 +29,50 @@
28
29
  }
29
30
 
30
31
  - (void)setLogLevel:(CDVInvokedUrlCommand*)command {
31
- NSInteger logLevel = [[command argumentAtIndex:0] intValue];
32
- [Purchasely setLogLevel:logLevel];
32
+ NSInteger logLevel = [[command argumentAtIndex:0] intValue];
33
+ [Purchasely setLogLevel:logLevel];
33
34
  }
34
35
 
35
36
  - (void)userLogin:(CDVInvokedUrlCommand*)command {
36
- NSString *userId = [command argumentAtIndex:0];
37
- [Purchasely userLoginWith:userId shouldRefresh:^(BOOL refresh) {
38
- [self successFor:command resultBool:refresh];
39
- }];
37
+ NSString *userId = [command argumentAtIndex:0];
38
+ [Purchasely userLoginWith:userId shouldRefresh:^(BOOL refresh) {
39
+ [self successFor:command resultBool:refresh];
40
+ }];
40
41
  }
41
42
 
42
43
  - (void)userLogout:(CDVInvokedUrlCommand*)command {
43
- [Purchasely userLogout];
44
+ [Purchasely userLogout];
44
45
  }
45
46
 
46
47
  - (void)setAttribute:(CDVInvokedUrlCommand*)command {
47
- NSInteger attribute = [[command argumentAtIndex:0] intValue];
48
- NSString *value = [command argumentAtIndex:1];
48
+ NSInteger attribute = [[command argumentAtIndex:0] intValue];
49
+ NSString *value = [command argumentAtIndex:1];
49
50
 
50
- [Purchasely setAttribute:attribute value:value];
51
+ [Purchasely setAttribute:attribute value:value];
51
52
  }
52
53
 
53
54
  - (void)getAnonymousUserId:(CDVInvokedUrlCommand*)command {
54
- NSString *anonymousId = [Purchasely anonymousUserId];
55
- [self successFor:command resultString:anonymousId];
55
+ NSString *anonymousId = [Purchasely anonymousUserId];
56
+ [self successFor:command resultString:anonymousId];
56
57
  }
57
58
 
58
59
  - (void)isReadyToPurchase:(CDVInvokedUrlCommand*)command {
59
- BOOL isReadyToPurchase = [[command argumentAtIndex:0] boolValue];
60
- [Purchasely isReadyToPurchase: isReadyToPurchase];
60
+ BOOL isReadyToPurchase = [[command argumentAtIndex:0] boolValue];
61
+ [Purchasely isReadyToPurchase: isReadyToPurchase];
61
62
  }
62
63
 
63
64
  - (void)setDefaultPresentationResultHandler:(CDVInvokedUrlCommand*)command {
64
- [Purchasely setDefaultPresentationResultHandler:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
65
- NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
65
+ [Purchasely setDefaultPresentationResultHandler:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
66
+ NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
66
67
 
67
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultDict];
68
- [pluginResult setKeepCallbackAsBool:YES];
69
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
70
- }];
68
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultDict];
69
+ [pluginResult setKeepCallbackAsBool:YES];
70
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
71
+ }];
71
72
  }
72
73
 
73
74
  - (void)presentPresentationWithIdentifier:(CDVInvokedUrlCommand*)command {
74
- NSString *presentationVendorId = [command argumentAtIndex:0];
75
+ NSString *presentationVendorId = [command argumentAtIndex:0];
75
76
  NSString *contentId = [command argumentAtIndex:1];
76
77
  BOOL isFullscreen = [[command argumentAtIndex:2] boolValue];
77
78
 
@@ -96,16 +97,42 @@
96
97
  }
97
98
  }
98
99
 
100
+ - (void)presentPresentationForPlacement:(CDVInvokedUrlCommand*)command {
101
+ NSString *placementVendorId = [command argumentAtIndex:0];
102
+ NSString *contentId = [command argumentAtIndex:1];
103
+ BOOL isFullscreen = [[command argumentAtIndex:2] boolValue];
104
+
105
+ UIViewController *ctrl = [Purchasely presentationControllerFor:placementVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
106
+ NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
107
+ [self successFor:command resultDict:resultDict];
108
+ }];
109
+
110
+ if (ctrl != nil) {
111
+ UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
112
+ [navCtrl.navigationBar setTranslucent:YES];
113
+ [navCtrl.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
114
+ [navCtrl.navigationBar setShadowImage: [UIImage new]];
115
+ [navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
116
+
117
+ self.presentedPresentationViewController = navCtrl;
118
+
119
+ if (isFullscreen) {
120
+ navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
121
+ }
122
+ [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
123
+ }
124
+ }
125
+
99
126
  - (void)presentPlanWithIdentifier:(CDVInvokedUrlCommand*)command {
100
- NSString *planVendorId = [command argumentAtIndex:0];
101
- NSString *presentationVendorId = [command argumentAtIndex:1];
127
+ NSString *planVendorId = [command argumentAtIndex:0];
128
+ NSString *presentationVendorId = [command argumentAtIndex:1];
102
129
  NSString *contentId = [command argumentAtIndex:2];
103
130
  BOOL isFullscreen = [[command argumentAtIndex:3] boolValue];
104
131
 
105
132
  UIViewController *ctrl = [Purchasely planControllerFor:planVendorId with:presentationVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
106
- NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
107
- [self successFor:command resultDict:resultDict];
108
- }];
133
+ NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
134
+ [self successFor:command resultDict:resultDict];
135
+ }];
109
136
 
110
137
  if (ctrl != nil) {
111
138
  UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
@@ -124,15 +151,15 @@
124
151
  }
125
152
 
126
153
  - (void)presentProductWithIdentifier:(CDVInvokedUrlCommand*)command {
127
- NSString *productVendorId = [command argumentAtIndex:0];
128
- NSString *presentationVendorId = [command argumentAtIndex:1];
154
+ NSString *productVendorId = [command argumentAtIndex:0];
155
+ NSString *presentationVendorId = [command argumentAtIndex:1];
129
156
  NSString *contentId = [command argumentAtIndex:2];
130
157
  BOOL isFullscreen = [[command argumentAtIndex:3] boolValue];
131
158
 
132
159
  UIViewController *ctrl = [Purchasely productControllerFor:productVendorId with:presentationVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
133
- NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
134
- [self successFor:command resultDict:resultDict];
135
- }];
160
+ NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
161
+ [self successFor:command resultDict:resultDict];
162
+ }];
136
163
 
137
164
  if (ctrl != nil) {
138
165
  UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
@@ -151,163 +178,163 @@
151
178
  }
152
179
 
153
180
  - (void)presentSubscriptions:(CDVInvokedUrlCommand*)command {
154
- UIViewController *ctrl = [Purchasely subscriptionsController];
155
- UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
156
- ctrl.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target:navCtrl action:@selector(close)];
181
+ UIViewController *ctrl = [Purchasely subscriptionsController];
182
+ UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
183
+ ctrl.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target:navCtrl action:@selector(close)];
157
184
 
158
- [Purchasely showController:navCtrl type: PLYUIControllerTypeSubscriptionList];
185
+ [Purchasely showController:navCtrl type: PLYUIControllerTypeSubscriptionList];
159
186
  }
160
187
 
161
188
  - (void)purchaseWithPlanVendorId:(CDVInvokedUrlCommand*)command {
162
- NSString *planVendorId = [command argumentAtIndex:0];
163
-
164
- [Purchasely planWith:planVendorId
165
- success:^(PLYPlan * _Nonnull plan) {
166
- [Purchasely purchaseWithPlan:plan
167
- success:^{
168
- [self successFor:command resultDict: plan.asDictionary];
169
- }
170
- failure:^(NSError * _Nonnull error) {
171
- [self failureFor:command resultString: error.localizedDescription];
172
- }];
173
- }
174
- failure:^(NSError * _Nullable error) {
175
- [self failureFor:command resultString: error.localizedDescription];
176
- }];
189
+ NSString *planVendorId = [command argumentAtIndex:0];
190
+
191
+ [Purchasely planWith:planVendorId
192
+ success:^(PLYPlan * _Nonnull plan) {
193
+ [Purchasely purchaseWithPlan:plan
194
+ success:^{
195
+ [self successFor:command resultDict: plan.asDictionary];
196
+ }
197
+ failure:^(NSError * _Nonnull error) {
198
+ [self failureFor:command resultString: error.localizedDescription];
199
+ }];
200
+ }
201
+ failure:^(NSError * _Nullable error) {
202
+ [self failureFor:command resultString: error.localizedDescription];
203
+ }];
177
204
  }
178
205
 
179
206
  - (void)restoreAllProducts:(CDVInvokedUrlCommand*)command {
180
- [Purchasely restoreAllProductsWithSuccess:^{
181
- [self successFor:command];
182
- } failure:^(NSError * _Nonnull error) {
183
- [self failureFor:command resultString:error.localizedDescription];
184
- }];
207
+ [Purchasely restoreAllProductsWithSuccess:^{
208
+ [self successFor:command];
209
+ } failure:^(NSError * _Nonnull error) {
210
+ [self failureFor:command resultString:error.localizedDescription];
211
+ }];
185
212
  }
186
213
 
187
214
  - (void)silentRestoreAllProducts:(CDVInvokedUrlCommand*)command {
188
- [Purchasely silentRestoreAllProductsWithSuccess:^{
189
- [self successFor:command];
190
- } failure:^(NSError * _Nonnull error) {
191
- [self failureFor:command resultString:error.localizedDescription];
192
- }];
215
+ [Purchasely silentRestoreAllProductsWithSuccess:^{
216
+ [self successFor:command];
217
+ } failure:^(NSError * _Nonnull error) {
218
+ [self failureFor:command resultString:error.localizedDescription];
219
+ }];
193
220
  }
194
221
 
195
222
  - (void)purchasedSubscription:(CDVInvokedUrlCommand*)command {
196
- self.purchasedCommand = command;
197
- [[NSNotificationCenter defaultCenter] addObserver:self
198
- selector:@selector(reloadContent:)
199
- name: @"ply_purchasedSubscription"
200
- object:nil];
223
+ self.purchasedCommand = command;
224
+ [[NSNotificationCenter defaultCenter] addObserver:self
225
+ selector:@selector(reloadContent:)
226
+ name: @"ply_purchasedSubscription"
227
+ object:nil];
201
228
  }
202
229
 
203
230
  - (void)allProducts:(CDVInvokedUrlCommand*)command {
204
- [Purchasely allProductsWithSuccess:^(NSArray<PLYProduct *> * _Nonnull products) {
205
- NSMutableArray *productsArray = [NSMutableArray array];
231
+ [Purchasely allProductsWithSuccess:^(NSArray<PLYProduct *> * _Nonnull products) {
232
+ NSMutableArray *productsArray = [NSMutableArray array];
206
233
 
207
- for (PLYProduct *product in products) {
208
- if (product != nil) {
209
- [productsArray addObject: product.asDictionary];
210
- }
211
- }
234
+ for (PLYProduct *product in products) {
235
+ if (product != nil) {
236
+ [productsArray addObject: product.asDictionary];
237
+ }
238
+ }
212
239
 
213
- [self successFor:command resultArray:productsArray];
214
- } failure:^(NSError * _Nullable error) {
215
- [self failureFor:command resultString:error.localizedDescription];
216
- }];
240
+ [self successFor:command resultArray:productsArray];
241
+ } failure:^(NSError * _Nullable error) {
242
+ [self failureFor:command resultString:error.localizedDescription];
243
+ }];
217
244
  }
218
245
 
219
246
  - (void)productWithIdentifier:(CDVInvokedUrlCommand*)command {
220
- NSString *productVendorId = [command argumentAtIndex:0];
247
+ NSString *productVendorId = [command argumentAtIndex:0];
221
248
 
222
- [Purchasely productWith:productVendorId
223
- success:^(PLYProduct * _Nonnull product) {
224
- [self successFor:command resultDict:product.asDictionary];
225
- }
226
- failure:^(NSError * _Nullable error) {
227
- [self failureFor:command resultString:error.localizedDescription];
228
- }];
249
+ [Purchasely productWith:productVendorId
250
+ success:^(PLYProduct * _Nonnull product) {
251
+ [self successFor:command resultDict:product.asDictionary];
252
+ }
253
+ failure:^(NSError * _Nullable error) {
254
+ [self failureFor:command resultString:error.localizedDescription];
255
+ }];
229
256
  }
230
257
 
231
258
  - (void)planWithIdentifier:(CDVInvokedUrlCommand*)command {
232
- NSString *planVendorId = [command argumentAtIndex:0];
259
+ NSString *planVendorId = [command argumentAtIndex:0];
233
260
 
234
- [Purchasely planWith:planVendorId
235
- success:^(PLYPlan * _Nonnull plan) {
236
- [self successFor:command resultDict:plan.asDictionary];
237
- }
238
- failure:^(NSError * _Nullable error) {
239
- [self failureFor:command resultString:error.localizedDescription];
240
- }];
261
+ [Purchasely planWith:planVendorId
262
+ success:^(PLYPlan * _Nonnull plan) {
263
+ [self successFor:command resultDict:plan.asDictionary];
264
+ }
265
+ failure:^(NSError * _Nullable error) {
266
+ [self failureFor:command resultString:error.localizedDescription];
267
+ }];
241
268
  }
242
269
 
243
270
  - (void)userSubscriptions:(CDVInvokedUrlCommand*)command {
244
- [Purchasely userSubscriptionsWithSuccess:^(NSArray<PLYSubscription *> * _Nullable subscriptions) {
245
- NSMutableArray *result = [NSMutableArray new];
246
- for (PLYSubscription *subscription in subscriptions) {
247
- [result addObject:subscription.asDictionary];
248
- }
249
- [self successFor:command resultArray:result];
250
- }
251
- failure:^(NSError * _Nonnull error) {
252
- [self failureFor:command resultString:error.localizedDescription];
253
- }];
271
+ [Purchasely userSubscriptionsWithSuccess:^(NSArray<PLYSubscription *> * _Nullable subscriptions) {
272
+ NSMutableArray *result = [NSMutableArray new];
273
+ for (PLYSubscription *subscription in subscriptions) {
274
+ [result addObject:subscription.asDictionary];
275
+ }
276
+ [self successFor:command resultArray:result];
277
+ }
278
+ failure:^(NSError * _Nonnull error) {
279
+ [self failureFor:command resultString:error.localizedDescription];
280
+ }];
254
281
  }
255
282
 
256
283
  - (void)addEventsListener:(CDVInvokedUrlCommand*)command {
257
- [Purchasely setEventDelegate:self];
258
- self.eventCommand = command;
284
+ [Purchasely setEventDelegate:self];
285
+ self.eventCommand = command;
259
286
  }
260
287
 
261
288
  - (void)removeEventsListener:(CDVInvokedUrlCommand*)command {
262
- [Purchasely setEventDelegate:nil];
263
- self.eventCommand = nil;
289
+ [Purchasely setEventDelegate:nil];
290
+ self.eventCommand = nil;
264
291
  }
265
292
 
266
293
  - (void)handle:(CDVInvokedUrlCommand*)command {
267
- NSString *deeplinkString = [command argumentAtIndex:0];
268
- NSURL *deeplink = [NSURL URLWithString:deeplinkString];
269
-
270
- if (deeplink != nil) {
271
- BOOL result = [Purchasely handleWithDeeplink:deeplink];
272
- [self successFor:command resultBool:result];
273
- } else {
274
- [self successFor:command resultBool:NO];
275
- }
294
+ NSString *deeplinkString = [command argumentAtIndex:0];
295
+ NSURL *deeplink = [NSURL URLWithString:deeplinkString];
296
+
297
+ if (deeplink != nil) {
298
+ BOOL result = [Purchasely handleWithDeeplink:deeplink];
299
+ [self successFor:command resultBool:result];
300
+ } else {
301
+ [self successFor:command resultBool:NO];
302
+ }
276
303
  }
277
304
 
278
305
  - (void)close:(CDVInvokedUrlCommand*)command {
279
306
  }
280
307
 
281
308
  - (void)setLanguage:(CDVInvokedUrlCommand*)command {
282
- NSString *language = [command argumentAtIndex:0];
283
- NSLocale *locale = [NSLocale localeWithLocaleIdentifier:language];
284
- [Purchasely setLanguageFrom:locale];
309
+ NSString *language = [command argumentAtIndex:0];
310
+ NSLocale *locale = [NSLocale localeWithLocaleIdentifier:language];
311
+ [Purchasely setLanguageFrom:locale];
285
312
  }
286
313
 
287
314
  // Helpers
288
315
 
289
316
  - (NSDictionary<NSString *, NSObject *> *) resultDictionaryForPresentationController:(PLYProductViewControllerResult)result plan:(PLYPlan * _Nullable)plan {
290
- NSMutableDictionary<NSString *, NSObject *> *productViewResult = [NSMutableDictionary new];
291
- int resultString;
317
+ NSMutableDictionary<NSString *, NSObject *> *productViewResult = [NSMutableDictionary new];
318
+ int resultString;
292
319
 
293
- switch (result) {
294
- case PLYProductViewControllerResultPurchased:
295
- resultString = PLYProductViewControllerResultPurchased;
296
- break;
297
- case PLYProductViewControllerResultRestored:
298
- resultString = PLYProductViewControllerResultRestored;
299
- break;
300
- case PLYProductViewControllerResultCancelled:
301
- resultString = PLYProductViewControllerResultCancelled;
302
- break;
303
- }
320
+ switch (result) {
321
+ case PLYProductViewControllerResultPurchased:
322
+ resultString = PLYProductViewControllerResultPurchased;
323
+ break;
324
+ case PLYProductViewControllerResultRestored:
325
+ resultString = PLYProductViewControllerResultRestored;
326
+ break;
327
+ case PLYProductViewControllerResultCancelled:
328
+ resultString = PLYProductViewControllerResultCancelled;
329
+ break;
330
+ }
304
331
 
305
- [productViewResult setObject:[NSNumber numberWithInt:resultString] forKey:@"result"];
332
+ [productViewResult setObject:[NSNumber numberWithInt:resultString] forKey:@"result"];
306
333
 
307
- if (plan != nil) {
308
- [productViewResult setObject:[plan asDictionary] forKey:@"plan"];
309
- }
310
- return productViewResult;
334
+ if (plan != nil) {
335
+ [productViewResult setObject:[plan asDictionary] forKey:@"plan"];
336
+ }
337
+ return productViewResult;
311
338
  }
312
339
 
313
340
  - (NSDictionary<NSString *, NSObject *> *) resultDictionaryForActionInterceptor:(PLYPresentationAction) action
@@ -351,6 +378,16 @@
351
378
  if (infos.presentationId != nil) {
352
379
  [infosResult setObject:infos.presentationId forKey:@"presentationId"];
353
380
  }
381
+ if (infos.placementId != nil) {
382
+ [infosResult setObject:infos.placementId forKey:@"placementId"];
383
+ }
384
+ if (infos.abTestId != nil) {
385
+ [infosResult setObject:infos.abTestId forKey:@"abTestId"];
386
+ }
387
+ if (infos.abTestVariantId != nil) {
388
+ [infosResult setObject:infos.abTestVariantId forKey:@"abTestVariantId"];
389
+ }
390
+
354
391
  [actionInterceptorResult setObject:infosResult forKey:@"info"];
355
392
  }
356
393
  if (params != nil) {
@@ -404,43 +441,43 @@
404
441
  }
405
442
 
406
443
  - (void)successFor:(CDVInvokedUrlCommand *)command {
407
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
408
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
444
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
445
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
409
446
  }
410
447
 
411
448
  - (void)successFor:(CDVInvokedUrlCommand *)command resultBool:(BOOL)resultBool {
412
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:resultBool];
413
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
449
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:resultBool];
450
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
414
451
  }
415
452
 
416
453
  - (void)successFor:(CDVInvokedUrlCommand *)command resultString:(NSString *)resultString {
417
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:resultString];
418
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
454
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:resultString];
455
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
419
456
  }
420
457
 
421
458
  - (void)failureFor:(CDVInvokedUrlCommand *)command resultString:(NSString *)resultString {
422
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:resultString];
423
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
459
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:resultString];
460
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
424
461
  }
425
462
 
426
463
  - (void)successFor:(CDVInvokedUrlCommand *)command resultArray:(NSArray *)resultArray {
427
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:resultArray];
428
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
464
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:resultArray];
465
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
429
466
  }
430
467
 
431
468
  - (void)failureFor:(CDVInvokedUrlCommand *)command resultArray:(NSArray *)resultArray {
432
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsArray:resultArray];
433
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
469
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsArray:resultArray];
470
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
434
471
  }
435
472
 
436
473
  - (void)successFor:(CDVInvokedUrlCommand *)command resultDict:(NSDictionary *)resultDict {
437
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultDict];
438
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
474
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultDict];
475
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
439
476
  }
440
477
 
441
478
  - (void)failureFor:(CDVInvokedUrlCommand *)command resultDict:(NSDictionary *)resultDict {
442
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:resultDict];
443
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
479
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:resultDict];
480
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
444
481
  }
445
482
 
446
483
 
@@ -38,6 +38,11 @@
38
38
  if (amount != nil) {
39
39
  [dict setObject:amount forKey:@"amount"];
40
40
  }
41
+
42
+ NSString *localizedAmount = [self localizedPriceWithLanguage:nil];
43
+ if (localizedAmount != nil) {
44
+ [dict setObject:localizedAmount forKey:@"localizedAmount"];
45
+ }
41
46
 
42
47
  NSDecimalNumber *introAmount = [self introAmount];
43
48
  if (introAmount != nil) {
package/www/Purchasely.js CHANGED
@@ -3,7 +3,11 @@ var exec = require('cordova/exec');
3
3
  var defaultError = (e) => { console.log(e); }
4
4
 
5
5
  exports.startWithAPIKey = function (apiKey, stores, userId, logLevel, runningMode, success, error) {
6
- exec(success, error, 'Purchasely', 'startWithAPIKey', [apiKey, stores, userId, logLevel, runningMode]);
6
+ var cordovaSdkVersion = cordova.define.moduleMap['cordova/plugin_list'].exports['metadata']['cordova-plugin-purchasely']
7
+ if(!cordovaSdkVersion) {
8
+ cordovaSdkVersion = "2.2.0" //fallback if we cannot find version from metadata
9
+ }
10
+ exec(success, error, 'Purchasely', 'startWithAPIKey', [apiKey, stores, userId, logLevel, runningMode, cordovaSdkVersion]);
7
11
  };
8
12
 
9
13
  exports.addEventsListener = function (success, error) {
@@ -50,6 +54,10 @@ exports.presentPresentationWithIdentifier = function (presentationId, contentId,
50
54
  exec(success, error, 'Purchasely', 'presentPresentationWithIdentifier', [presentationId, contentId, isFullscreen]);
51
55
  };
52
56
 
57
+ exports.presentPresentationForPlacement = function (placementId, contentId, isFullscreen, success, error) {
58
+ exec(success, error, 'Purchasely', 'presentPresentationForPlacement', [placementId, contentId, isFullscreen]);
59
+ };
60
+
53
61
  exports.presentProductWithIdentifier = function (productId, presentationId, contentId, isFullscreen, success, error) {
54
62
  exec(success, error, 'Purchasely', 'presentProductWithIdentifier', [productId, presentationId, contentId, isFullscreen]);
55
63
  };
@@ -129,7 +137,10 @@ exports.Attribute = {
129
137
  AMPLITUDE_SESSION_ID: 0,
130
138
  FIREBASE_APP_INSTANCE_ID: 1,
131
139
  AIRSHIP_CHANNEL_ID: 2,
132
- BATCH_INSTALLATION_ID: 3
140
+ BATCH_INSTALLATION_ID: 3,
141
+ ADJUST_ID: 4,
142
+ APPSFLYER_ID: 5,
143
+ ONESIGNAL_PLAYER_ID: 6
133
144
  }
134
145
 
135
146
  exports.PurchaseResult = {