@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.
- package/VERSIONS.md +3 -0
- package/example/package-lock.json +210 -83
- package/example/package.json +1 -4
- package/example/www/js/index.js +4 -6
- package/package.json +1 -1
- package/plugin.xml +3 -3
- package/src/android/PLYProductActivity.java +4 -1
- package/src/android/PurchaselyPlugin.java +58 -19
- package/src/ios/CDVPurchasely.h +1 -0
- package/src/ios/CDVPurchasely.m +194 -157
- package/src/ios/Hybrid/PLYPlan+Hybrid.m +5 -0
- package/www/Purchasely.js +13 -2
package/src/ios/CDVPurchasely.m
CHANGED
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
@implementation CDVPurchasely
|
|
13
13
|
|
|
14
14
|
- (void)startWithAPIKey:(CDVInvokedUrlCommand*)command {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
32
|
+
NSInteger logLevel = [[command argumentAtIndex:0] intValue];
|
|
33
|
+
[Purchasely setLogLevel:logLevel];
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
- (void)userLogin:(CDVInvokedUrlCommand*)command {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
44
|
+
[Purchasely userLogout];
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
- (void)setAttribute:(CDVInvokedUrlCommand*)command {
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
NSInteger attribute = [[command argumentAtIndex:0] intValue];
|
|
49
|
+
NSString *value = [command argumentAtIndex:1];
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
[Purchasely setAttribute:attribute value:value];
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
- (void)getAnonymousUserId:(CDVInvokedUrlCommand*)command {
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
NSString *anonymousId = [Purchasely anonymousUserId];
|
|
56
|
+
[self successFor:command resultString:anonymousId];
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
- (void)isReadyToPurchase:(CDVInvokedUrlCommand*)command {
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
BOOL isReadyToPurchase = [[command argumentAtIndex:0] boolValue];
|
|
61
|
+
[Purchasely isReadyToPurchase: isReadyToPurchase];
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
- (void)setDefaultPresentationResultHandler:(CDVInvokedUrlCommand*)command {
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
[Purchasely setDefaultPresentationResultHandler:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
66
|
+
NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
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
|
-
|
|
101
|
-
|
|
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
|
-
|
|
107
|
-
|
|
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
|
-
|
|
128
|
-
|
|
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
|
-
|
|
134
|
-
|
|
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
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
185
|
+
[Purchasely showController:navCtrl type: PLYUIControllerTypeSubscriptionList];
|
|
159
186
|
}
|
|
160
187
|
|
|
161
188
|
- (void)purchaseWithPlanVendorId:(CDVInvokedUrlCommand*)command {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
-
|
|
205
|
-
|
|
231
|
+
[Purchasely allProductsWithSuccess:^(NSArray<PLYProduct *> * _Nonnull products) {
|
|
232
|
+
NSMutableArray *productsArray = [NSMutableArray array];
|
|
206
233
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
234
|
+
for (PLYProduct *product in products) {
|
|
235
|
+
if (product != nil) {
|
|
236
|
+
[productsArray addObject: product.asDictionary];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
212
239
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
|
|
247
|
+
NSString *productVendorId = [command argumentAtIndex:0];
|
|
221
248
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
-
|
|
259
|
+
NSString *planVendorId = [command argumentAtIndex:0];
|
|
233
260
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
|
|
258
|
-
|
|
284
|
+
[Purchasely setEventDelegate:self];
|
|
285
|
+
self.eventCommand = command;
|
|
259
286
|
}
|
|
260
287
|
|
|
261
288
|
- (void)removeEventsListener:(CDVInvokedUrlCommand*)command {
|
|
262
|
-
|
|
263
|
-
|
|
289
|
+
[Purchasely setEventDelegate:nil];
|
|
290
|
+
self.eventCommand = nil;
|
|
264
291
|
}
|
|
265
292
|
|
|
266
293
|
- (void)handle:(CDVInvokedUrlCommand*)command {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
291
|
-
|
|
317
|
+
NSMutableDictionary<NSString *, NSObject *> *productViewResult = [NSMutableDictionary new];
|
|
318
|
+
int resultString;
|
|
292
319
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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
|
-
|
|
332
|
+
[productViewResult setObject:[NSNumber numberWithInt:resultString] forKey:@"result"];
|
|
306
333
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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
|
-
|
|
408
|
-
|
|
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
|
-
|
|
413
|
-
|
|
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
|
-
|
|
418
|
-
|
|
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
|
-
|
|
423
|
-
|
|
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
|
-
|
|
428
|
-
|
|
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
|
-
|
|
433
|
-
|
|
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
|
-
|
|
438
|
-
|
|
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
|
-
|
|
443
|
-
|
|
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
|
-
|
|
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 = {
|