@purchasely/cordova-plugin-purchasely 1.1.8 → 2.1.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/README.md +16 -2
- package/VERSIONS.md +4 -0
- package/example/config.xml +10 -0
- package/example/package-lock.json +248 -76
- package/example/package.json +6 -5
- package/example/www/index.html +3 -0
- package/example/www/js/index.js +74 -14
- package/package.json +1 -1
- package/plugin.xml +6 -3
- package/src/android/.idea/workspace.xml +19 -1
- package/src/android/PLYProductActivity.java +19 -4
- package/src/android/PurchaselyPlugin.java +121 -52
- package/src/android/theme_purchasely_fullscreen.xml +6 -0
- package/src/android/theme_purchasely_fullscreen_v23.xml +6 -0
- package/src/android/theme_purchasely_fullscreen_v23_light_status_bar.xml +7 -0
- package/src/ios/CDVPurchasely.h +8 -11
- package/src/ios/CDVPurchasely.m +200 -83
- package/src/ios/Hybrid/PLYPlan+Hybrid.m +9 -0
- package/www/Purchasely.js +45 -29
- package/src/android/.idea/runConfigurations.xml +0 -10
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<resources>
|
|
2
|
+
<style name="Theme.Purchasely.Fullscreen.Light" parent="Theme.AppCompat.Light.NoActionBar">
|
|
3
|
+
<item name="android:navigationBarColor">@android:color/transparent</item>
|
|
4
|
+
<item name="android:statusBarColor">@android:color/transparent</item>
|
|
5
|
+
<item name="android:windowLightStatusBar">true</item>
|
|
6
|
+
</style>
|
|
7
|
+
</resources>
|
package/src/ios/CDVPurchasely.h
CHANGED
|
@@ -11,16 +11,13 @@
|
|
|
11
11
|
@interface CDVPurchasely<PLYEventDelegate> : CDVPlugin {
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
@property (nonatomic,
|
|
14
|
+
@property (nonatomic, assign) UIViewController* presentedPresentationViewController;
|
|
15
15
|
|
|
16
16
|
@property CDVInvokedUrlCommand* purchasedCommand;
|
|
17
17
|
@property CDVInvokedUrlCommand* eventCommand;
|
|
18
18
|
|
|
19
|
-
@property CDVInvokedUrlCommand*
|
|
20
|
-
@property void (^
|
|
21
|
-
|
|
22
|
-
@property CDVInvokedUrlCommand* authorizePurchaseCommand;
|
|
23
|
-
@property void (^authorizePurchaseHandler)(BOOL authorizePurchase);
|
|
19
|
+
@property CDVInvokedUrlCommand* paywallActionInterceptorCommand;
|
|
20
|
+
@property void (^onProcessActionHandler)(BOOL proceed);
|
|
24
21
|
|
|
25
22
|
- (void)startWithAPIKey:(CDVInvokedUrlCommand*)command;
|
|
26
23
|
- (void)setLogLevel:(CDVInvokedUrlCommand*)command;
|
|
@@ -31,11 +28,13 @@
|
|
|
31
28
|
- (void)isReadyToPurchase:(CDVInvokedUrlCommand*)command;
|
|
32
29
|
- (void)setDefaultPresentationResultHandler:(CDVInvokedUrlCommand*)command;
|
|
33
30
|
- (void)presentPresentationWithIdentifier:(CDVInvokedUrlCommand*)command;
|
|
31
|
+
- (void)presentPresentationForPlacement:(CDVInvokedUrlCommand*)command;
|
|
34
32
|
- (void)presentPlanWithIdentifier:(CDVInvokedUrlCommand*)command;
|
|
35
33
|
- (void)presentProductWithIdentifier:(CDVInvokedUrlCommand*)command;
|
|
36
34
|
- (void)presentSubscriptions:(CDVInvokedUrlCommand*)command;
|
|
37
35
|
- (void)purchaseWithPlanVendorId:(CDVInvokedUrlCommand*)command;
|
|
38
36
|
- (void)restoreAllProducts:(CDVInvokedUrlCommand*)command;
|
|
37
|
+
- (void)silentRestoreAllProducts:(CDVInvokedUrlCommand*)command;
|
|
39
38
|
- (void)purchasedSubscription:(CDVInvokedUrlCommand*)command;
|
|
40
39
|
- (void)allProducts:(CDVInvokedUrlCommand*)command;
|
|
41
40
|
- (void)productWithIdentifier:(CDVInvokedUrlCommand*)command;
|
|
@@ -45,10 +44,8 @@
|
|
|
45
44
|
- (void)removeEventsListener:(CDVInvokedUrlCommand*)command;
|
|
46
45
|
- (void)handle:(CDVInvokedUrlCommand*)command;
|
|
47
46
|
- (void)close:(CDVInvokedUrlCommand*)command;
|
|
48
|
-
- (void)
|
|
49
|
-
- (void)
|
|
50
|
-
- (void)
|
|
51
|
-
- (void)processToPayment:(CDVInvokedUrlCommand*)command;
|
|
52
|
-
|
|
47
|
+
- (void)setPaywallActionInterceptor:(CDVInvokedUrlCommand*)command;
|
|
48
|
+
- (void)onProcessAction:(CDVInvokedUrlCommand*)command;
|
|
49
|
+
- (void)closePaywall:(CDVInvokedUrlCommand*)command;
|
|
53
50
|
|
|
54
51
|
@end
|
package/src/ios/CDVPurchasely.m
CHANGED
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
NSString *apiKey = [command argumentAtIndex:0];
|
|
16
16
|
NSString *userId = [command argumentAtIndex:2];
|
|
17
17
|
NSInteger logLevel = [[command argumentAtIndex:3] intValue];
|
|
18
|
-
|
|
18
|
+
NSInteger runningMode = [[command argumentAtIndex:4] intValue];
|
|
19
19
|
|
|
20
|
-
[Purchasely startWithAPIKey:apiKey appUserId:userId observerMode:observerMode eventDelegate:nil uiDelegate:nil confirmPurchaseHandler:nil logLevel:logLevel initialized:^(BOOL initialized, NSError * _Nullable error) {
|
|
21
|
-
if (error != nil) {
|
|
22
|
-
[self failureFor:command resultString: error.localizedDescription];
|
|
23
|
-
} else {
|
|
24
|
-
[self successFor:command resultBool:initialized];
|
|
25
|
-
}
|
|
26
|
-
}];
|
|
27
20
|
[Purchasely setAppTechnology:PLYAppTechnologyCordova];
|
|
21
|
+
[Purchasely startWithAPIKey:apiKey appUserId:userId runningMode:runningMode eventDelegate:nil uiDelegate:nil paywallActionsInterceptor:nil logLevel:logLevel initialized:^(BOOL initialized, NSError * _Nullable error) {
|
|
22
|
+
if (error != nil) {
|
|
23
|
+
[self failureFor:command resultString: error.localizedDescription];
|
|
24
|
+
} else {
|
|
25
|
+
[self successFor:command resultBool:initialized];
|
|
26
|
+
}
|
|
27
|
+
}];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
- (void)setLogLevel:(CDVInvokedUrlCommand*)command {
|
|
@@ -72,61 +72,108 @@
|
|
|
72
72
|
|
|
73
73
|
- (void)presentPresentationWithIdentifier:(CDVInvokedUrlCommand*)command {
|
|
74
74
|
NSString *presentationVendorId = [command argumentAtIndex:0];
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
NSString *contentId = [command argumentAtIndex:1];
|
|
76
|
+
BOOL isFullscreen = [[command argumentAtIndex:2] boolValue];
|
|
77
|
+
|
|
78
|
+
UIViewController *ctrl = [Purchasely presentationControllerWith:presentationVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
79
|
+
NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
|
|
80
|
+
[self successFor:command resultDict:resultDict];
|
|
81
|
+
}];
|
|
82
|
+
|
|
83
|
+
if (ctrl != nil) {
|
|
84
|
+
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
|
|
85
|
+
[navCtrl.navigationBar setTranslucent:YES];
|
|
86
|
+
[navCtrl.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
|
87
|
+
[navCtrl.navigationBar setShadowImage: [UIImage new]];
|
|
88
|
+
[navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
|
|
89
|
+
|
|
90
|
+
self.presentedPresentationViewController = navCtrl;
|
|
91
|
+
|
|
92
|
+
if (isFullscreen) {
|
|
93
|
+
navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
94
|
+
}
|
|
95
|
+
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
- (void)presentPresentationForPlacement:(CDVInvokedUrlCommand*)command {
|
|
100
|
+
NSString *placementVendorId = [command argumentAtIndex:0];
|
|
101
|
+
NSString *contentId = [command argumentAtIndex:1];
|
|
102
|
+
BOOL isFullscreen = [[command argumentAtIndex:2] boolValue];
|
|
103
|
+
|
|
104
|
+
UIViewController *ctrl = [Purchasely presentationControllerFor:placementVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
105
|
+
NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
|
|
106
|
+
[self successFor:command resultDict:resultDict];
|
|
107
|
+
}];
|
|
108
|
+
|
|
109
|
+
if (ctrl != nil) {
|
|
110
|
+
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
|
|
111
|
+
[navCtrl.navigationBar setTranslucent:YES];
|
|
112
|
+
[navCtrl.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
|
113
|
+
[navCtrl.navigationBar setShadowImage: [UIImage new]];
|
|
114
|
+
[navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
|
|
115
|
+
|
|
116
|
+
self.presentedPresentationViewController = navCtrl;
|
|
117
|
+
|
|
118
|
+
if (isFullscreen) {
|
|
119
|
+
navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
120
|
+
}
|
|
121
|
+
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
|
|
122
|
+
}
|
|
90
123
|
}
|
|
91
124
|
|
|
92
125
|
- (void)presentPlanWithIdentifier:(CDVInvokedUrlCommand*)command {
|
|
93
126
|
NSString *planVendorId = [command argumentAtIndex:0];
|
|
94
127
|
NSString *presentationVendorId = [command argumentAtIndex:1];
|
|
95
|
-
|
|
96
|
-
|
|
128
|
+
NSString *contentId = [command argumentAtIndex:2];
|
|
129
|
+
BOOL isFullscreen = [[command argumentAtIndex:3] boolValue];
|
|
130
|
+
|
|
131
|
+
UIViewController *ctrl = [Purchasely planControllerFor:planVendorId with:presentationVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
97
132
|
NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
|
|
98
133
|
[self successFor:command resultDict:resultDict];
|
|
99
134
|
}];
|
|
100
135
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
136
|
+
if (ctrl != nil) {
|
|
137
|
+
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
|
|
138
|
+
[navCtrl.navigationBar setTranslucent:YES];
|
|
139
|
+
[navCtrl.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
|
140
|
+
[navCtrl.navigationBar setShadowImage: [UIImage new]];
|
|
141
|
+
[navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
|
|
142
|
+
|
|
143
|
+
self.presentedPresentationViewController = navCtrl;
|
|
144
|
+
|
|
145
|
+
if (isFullscreen) {
|
|
146
|
+
navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
147
|
+
}
|
|
148
|
+
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
|
|
149
|
+
}
|
|
110
150
|
}
|
|
111
151
|
|
|
112
152
|
- (void)presentProductWithIdentifier:(CDVInvokedUrlCommand*)command {
|
|
113
153
|
NSString *productVendorId = [command argumentAtIndex:0];
|
|
114
154
|
NSString *presentationVendorId = [command argumentAtIndex:1];
|
|
115
|
-
|
|
116
|
-
|
|
155
|
+
NSString *contentId = [command argumentAtIndex:2];
|
|
156
|
+
BOOL isFullscreen = [[command argumentAtIndex:3] boolValue];
|
|
157
|
+
|
|
158
|
+
UIViewController *ctrl = [Purchasely productControllerFor:productVendorId with:presentationVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
117
159
|
NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
|
|
118
160
|
[self successFor:command resultDict:resultDict];
|
|
119
161
|
}];
|
|
120
162
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
163
|
+
if (ctrl != nil) {
|
|
164
|
+
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
|
|
165
|
+
[navCtrl.navigationBar setTranslucent:YES];
|
|
166
|
+
[navCtrl.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
|
167
|
+
[navCtrl.navigationBar setShadowImage: [UIImage new]];
|
|
168
|
+
[navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
|
|
169
|
+
|
|
170
|
+
self.presentedPresentationViewController = navCtrl;
|
|
171
|
+
|
|
172
|
+
if (isFullscreen) {
|
|
173
|
+
navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
174
|
+
}
|
|
175
|
+
[Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
|
|
176
|
+
}
|
|
130
177
|
}
|
|
131
178
|
|
|
132
179
|
- (void)presentSubscriptions:(CDVInvokedUrlCommand*)command {
|
|
@@ -163,6 +210,14 @@
|
|
|
163
210
|
}];
|
|
164
211
|
}
|
|
165
212
|
|
|
213
|
+
- (void)silentRestoreAllProducts:(CDVInvokedUrlCommand*)command {
|
|
214
|
+
[Purchasely silentRestoreAllProductsWithSuccess:^{
|
|
215
|
+
[self successFor:command];
|
|
216
|
+
} failure:^(NSError * _Nonnull error) {
|
|
217
|
+
[self failureFor:command resultString:error.localizedDescription];
|
|
218
|
+
}];
|
|
219
|
+
}
|
|
220
|
+
|
|
166
221
|
- (void)purchasedSubscription:(CDVInvokedUrlCommand*)command {
|
|
167
222
|
self.purchasedCommand = command;
|
|
168
223
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
@@ -249,44 +304,10 @@
|
|
|
249
304
|
- (void)close:(CDVInvokedUrlCommand*)command {
|
|
250
305
|
}
|
|
251
306
|
|
|
252
|
-
- (void)
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
[self.presentedPresentationViewController dismissViewControllerAnimated:true completion:^{
|
|
258
|
-
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
259
|
-
[result setKeepCallbackAsBool:YES];
|
|
260
|
-
[self.commandDelegate sendPluginResult:result callbackId:self.loginTappedCommand.callbackId];
|
|
261
|
-
}];
|
|
262
|
-
}];
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
- (void)onUserLoggedIn:(CDVInvokedUrlCommand*)command {
|
|
266
|
-
BOOL userDidLogin = [[command argumentAtIndex:0] boolValue];
|
|
267
|
-
|
|
268
|
-
[Purchasely showController:self.presentedPresentationViewController type: PLYUIControllerTypeProductPage];
|
|
269
|
-
self.loginClosedHandler(userDidLogin);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
- (void)setConfirmPurchaseHandler:(CDVInvokedUrlCommand*)command {
|
|
273
|
-
self.authorizePurchaseCommand = command;
|
|
274
|
-
[Purchasely setConfirmPurchaseHandler:^(UIViewController * _Nonnull controller, void (^ _Nonnull authorizePurchaseHandler)(BOOL)) {
|
|
275
|
-
self.authorizePurchaseHandler = authorizePurchaseHandler;
|
|
276
|
-
|
|
277
|
-
[self.presentedPresentationViewController dismissViewControllerAnimated:true completion:^{
|
|
278
|
-
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
279
|
-
[result setKeepCallbackAsBool:YES];
|
|
280
|
-
[self.commandDelegate sendPluginResult:result callbackId:self.authorizePurchaseCommand.callbackId];
|
|
281
|
-
}];
|
|
282
|
-
}];
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
- (void)processToPayment:(CDVInvokedUrlCommand*)command {
|
|
286
|
-
BOOL processToPayment = [[command argumentAtIndex:0] boolValue];
|
|
287
|
-
|
|
288
|
-
[Purchasely showController:self.presentedPresentationViewController type: PLYUIControllerTypeProductPage];
|
|
289
|
-
self.authorizePurchaseHandler(processToPayment);
|
|
307
|
+
- (void)setLanguage:(CDVInvokedUrlCommand*)command {
|
|
308
|
+
NSString *language = [command argumentAtIndex:0];
|
|
309
|
+
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:language];
|
|
310
|
+
[Purchasely setLanguageFrom:locale];
|
|
290
311
|
}
|
|
291
312
|
|
|
292
313
|
// Helpers
|
|
@@ -315,6 +336,102 @@
|
|
|
315
336
|
return productViewResult;
|
|
316
337
|
}
|
|
317
338
|
|
|
339
|
+
- (NSDictionary<NSString *, NSObject *> *) resultDictionaryForActionInterceptor:(PLYPresentationAction) action
|
|
340
|
+
parameters: (PLYPresentationActionParameters * _Nullable) params
|
|
341
|
+
presentationInfos: (PLYPresentationInfo * _Nullable) infos {
|
|
342
|
+
NSMutableDictionary<NSString *, NSObject *> *actionInterceptorResult = [NSMutableDictionary new];
|
|
343
|
+
|
|
344
|
+
NSString* actionString;
|
|
345
|
+
|
|
346
|
+
switch (action) {
|
|
347
|
+
case PLYPresentationActionLogin:
|
|
348
|
+
actionString = @"login";
|
|
349
|
+
break;
|
|
350
|
+
case PLYPresentationActionPurchase:
|
|
351
|
+
actionString = @"purchase";
|
|
352
|
+
break;
|
|
353
|
+
case PLYPresentationActionClose:
|
|
354
|
+
actionString = @"close";
|
|
355
|
+
break;
|
|
356
|
+
case PLYPresentationActionRestore:
|
|
357
|
+
actionString = @"restore";
|
|
358
|
+
break;
|
|
359
|
+
case PLYPresentationActionNavigate:
|
|
360
|
+
actionString = @"navigate";
|
|
361
|
+
break;
|
|
362
|
+
case PLYPresentationActionPromoCode:
|
|
363
|
+
actionString = @"promo_code";
|
|
364
|
+
break;
|
|
365
|
+
case PLYPresentationActionOpenPresentation:
|
|
366
|
+
actionString = @"open_presentation";
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
[actionInterceptorResult setObject:actionString forKey:@"action"];
|
|
371
|
+
|
|
372
|
+
if (infos != nil) {
|
|
373
|
+
NSMutableDictionary<NSString *, NSObject *> *infosResult = [NSMutableDictionary new];
|
|
374
|
+
if (infos.contentId != nil) {
|
|
375
|
+
[infosResult setObject:infos.contentId forKey:@"contentId"];
|
|
376
|
+
}
|
|
377
|
+
if (infos.presentationId != nil) {
|
|
378
|
+
[infosResult setObject:infos.presentationId forKey:@"presentationId"];
|
|
379
|
+
}
|
|
380
|
+
if (infos.placementId != nil) {
|
|
381
|
+
[infosResult setObject:infos.placementId forKey:@"placementId"];
|
|
382
|
+
}
|
|
383
|
+
[actionInterceptorResult setObject:infosResult forKey:@"info"];
|
|
384
|
+
}
|
|
385
|
+
if (params != nil) {
|
|
386
|
+
NSMutableDictionary<NSString *, NSObject *> *paramsResult = [NSMutableDictionary new];
|
|
387
|
+
if (params.url != nil) {
|
|
388
|
+
[paramsResult setObject:params.url.absoluteString forKey:@"url"];
|
|
389
|
+
}
|
|
390
|
+
if (params.plan != nil) {
|
|
391
|
+
[paramsResult setObject:[params.plan asDictionary] forKey:@"plan"];
|
|
392
|
+
}
|
|
393
|
+
if (params.title != nil) {
|
|
394
|
+
[paramsResult setObject:params.title forKey:@"title"];
|
|
395
|
+
}
|
|
396
|
+
if (params.presentation != nil) {
|
|
397
|
+
[paramsResult setObject:params.presentation forKey:@"presentation"];
|
|
398
|
+
}
|
|
399
|
+
[actionInterceptorResult setObject:paramsResult forKey:@"parameters"];
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return actionInterceptorResult;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
- (void)setPaywallActionInterceptor:(CDVInvokedUrlCommand*)command {
|
|
406
|
+
self.paywallActionInterceptorCommand = command;
|
|
407
|
+
[Purchasely setPaywallActionsInterceptor:^(enum PLYPresentationAction action, PLYPresentationActionParameters * _Nullable parameters, PLYPresentationInfo * _Nullable infos, void (^ _Nonnull onProcessActionHandler)(BOOL)) {
|
|
408
|
+
self.onProcessActionHandler = onProcessActionHandler;
|
|
409
|
+
NSDictionary *resultDict = [self resultDictionaryForActionInterceptor:action parameters:parameters presentationInfos:infos];
|
|
410
|
+
|
|
411
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultDict];
|
|
412
|
+
[pluginResult setKeepCallbackAsBool:YES];
|
|
413
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.paywallActionInterceptorCommand.callbackId];
|
|
414
|
+
|
|
415
|
+
}];
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
- (void)onProcessAction:(CDVInvokedUrlCommand*)command {
|
|
419
|
+
BOOL processAction = [[command argumentAtIndex:0] boolValue];
|
|
420
|
+
if (self.onProcessActionHandler != nil) {
|
|
421
|
+
self.onProcessActionHandler(processAction);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
- (void)closePaywall:(CDVInvokedUrlCommand*)command {
|
|
426
|
+
if (self.presentedPresentationViewController != nil) {
|
|
427
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
428
|
+
[self.presentedPresentationViewController dismissViewControllerAnimated:true completion:^{
|
|
429
|
+
self.presentedPresentationViewController = nil;
|
|
430
|
+
}];
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
318
435
|
- (void)successFor:(CDVInvokedUrlCommand *)command {
|
|
319
436
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
320
437
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
[dict setObject:self.name forKey:@"name"];
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
if (self.appleProductId != nil) {
|
|
29
|
+
[dict setObject:self.appleProductId forKey:@"productId"];
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
NSString *price = [self localizedFullPriceWithLanguage:nil];
|
|
29
33
|
if (price != nil) {
|
|
30
34
|
[dict setObject:price forKey:@"price"];
|
|
@@ -34,6 +38,11 @@
|
|
|
34
38
|
if (amount != nil) {
|
|
35
39
|
[dict setObject:amount forKey:@"amount"];
|
|
36
40
|
}
|
|
41
|
+
|
|
42
|
+
NSString *localizedAmount = [self localizedPriceWithLanguage:nil];
|
|
43
|
+
if (localizedAmount != nil) {
|
|
44
|
+
[dict setObject:localizedAmount forKey:@"localizedAmount"];
|
|
45
|
+
}
|
|
37
46
|
|
|
38
47
|
NSDecimalNumber *introAmount = [self introAmount];
|
|
39
48
|
if (introAmount != nil) {
|
package/www/Purchasely.js
CHANGED
|
@@ -2,8 +2,8 @@ var exec = require('cordova/exec');
|
|
|
2
2
|
|
|
3
3
|
var defaultError = (e) => { console.log(e); }
|
|
4
4
|
|
|
5
|
-
exports.startWithAPIKey = function (apiKey, stores, userId, logLevel,
|
|
6
|
-
exec(success, error, 'Purchasely', 'startWithAPIKey', [apiKey, stores, userId, logLevel,
|
|
5
|
+
exports.startWithAPIKey = function (apiKey, stores, userId, logLevel, runningMode, success, error) {
|
|
6
|
+
exec(success, error, 'Purchasely', 'startWithAPIKey', [apiKey, stores, userId, logLevel, runningMode]);
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
exports.addEventsListener = function (success, error) {
|
|
@@ -46,28 +46,20 @@ exports.synchronize = function () {
|
|
|
46
46
|
exec(() => {}, defaultError, 'Purchasely', 'synchronize', []);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
exports.presentPresentationWithIdentifier = function (presentationId, contentId, success, error) {
|
|
50
|
-
exec(success, error, 'Purchasely', 'presentPresentationWithIdentifier', [presentationId, contentId]);
|
|
49
|
+
exports.presentPresentationWithIdentifier = function (presentationId, contentId, isFullscreen, success, error) {
|
|
50
|
+
exec(success, error, 'Purchasely', 'presentPresentationWithIdentifier', [presentationId, contentId, isFullscreen]);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
exports.
|
|
54
|
-
exec(success, error, 'Purchasely', '
|
|
53
|
+
exports.presentPresentationForPlacement = function (placementId, contentId, isFullscreen, success, error) {
|
|
54
|
+
exec(success, error, 'Purchasely', 'presentPresentationForPlacement', [placementId, contentId, isFullscreen]);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
exports.presentProductWithIdentifier = function (productId, presentationId, contentId, success, error) {
|
|
58
|
-
exec(success, error, 'Purchasely', 'presentProductWithIdentifier', [productId, presentationId, contentId]);
|
|
57
|
+
exports.presentProductWithIdentifier = function (productId, presentationId, contentId, isFullscreen, success, error) {
|
|
58
|
+
exec(success, error, 'Purchasely', 'presentProductWithIdentifier', [productId, presentationId, contentId, isFullscreen]);
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
exports.
|
|
62
|
-
exec(success, error, 'Purchasely', '
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
exports.presentPlanWithIdentifier = function (planId, presentationId, contentId, success, error) {
|
|
66
|
-
exec(success, error, 'Purchasely', 'presentPlanWithIdentifier', [planId, presentationId, contentId]);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
exports.presentPlanWithIdentifier = function (planId, presentationId, success, error) {
|
|
70
|
-
exec(success, error, 'Purchasely', 'presentPlanWithIdentifier', [planId, presentationId, null]);
|
|
61
|
+
exports.presentPlanWithIdentifier = function (planId, presentationId, contentId, isFullscreen, success, error) {
|
|
62
|
+
exec(success, error, 'Purchasely', 'presentPlanWithIdentifier', [planId, presentationId, contentId, isFullscreen]);
|
|
71
63
|
};
|
|
72
64
|
|
|
73
65
|
exports.presentSubscriptions = function () {
|
|
@@ -86,6 +78,10 @@ exports.restoreAllProducts = function (success, error) {
|
|
|
86
78
|
exec(success, error, 'Purchasely', 'restoreAllProducts', []);
|
|
87
79
|
};
|
|
88
80
|
|
|
81
|
+
exports.silentRestoreAllProducts = function (success, error) {
|
|
82
|
+
exec(success, error, 'Purchasely', 'silentRestoreAllProducts', []);
|
|
83
|
+
};
|
|
84
|
+
|
|
89
85
|
exports.purchasedSubscription = function (success, error) {
|
|
90
86
|
exec(success, error, 'Purchasely', 'purchasedSubscription', []);
|
|
91
87
|
};
|
|
@@ -106,26 +102,26 @@ exports.productWithIdentifier = function (productId, success) {
|
|
|
106
102
|
exec(success, defaultError, 'Purchasely', 'productWithIdentifier', [productId]);
|
|
107
103
|
};
|
|
108
104
|
|
|
109
|
-
exports.
|
|
110
|
-
exec(success, defaultError, 'Purchasely', '
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
exports.onUserLoggedIn = function (userLoggedIn) {
|
|
114
|
-
exec(() => {}, defaultError, 'Purchasely', 'onUserLoggedIn', [userLoggedIn]);
|
|
105
|
+
exports.setPaywallActionInterceptor = function (success) {
|
|
106
|
+
exec(success, defaultError, 'Purchasely', 'setPaywallActionInterceptor', []);
|
|
115
107
|
};
|
|
116
108
|
|
|
117
|
-
exports.
|
|
118
|
-
exec(
|
|
109
|
+
exports.onProcessAction = function (processAction) {
|
|
110
|
+
exec(() => {}, defaultError, 'Purchasely', 'onProcessAction', [processAction]);
|
|
119
111
|
};
|
|
120
112
|
|
|
121
|
-
exports.
|
|
122
|
-
exec(() => {}, defaultError, 'Purchasely', '
|
|
113
|
+
exports.closePaywall = function () {
|
|
114
|
+
exec(() => {}, defaultError, 'Purchasely', 'closePaywall', []);
|
|
123
115
|
};
|
|
124
116
|
|
|
125
117
|
exports.userSubscriptions = function (success, error) {
|
|
126
118
|
exec(success, defaultError, 'Purchasely', 'userSubscriptions', []);
|
|
127
119
|
};
|
|
128
120
|
|
|
121
|
+
exports.setLanguage = function (language) {
|
|
122
|
+
exec(() => {}, defaultError, 'Purchasely', 'setLanguage', [language]);
|
|
123
|
+
};
|
|
124
|
+
|
|
129
125
|
exports.LogLevel = {
|
|
130
126
|
DEBUG: 0,
|
|
131
127
|
INFO: 1,
|
|
@@ -136,7 +132,8 @@ exports.LogLevel = {
|
|
|
136
132
|
exports.Attribute = {
|
|
137
133
|
AMPLITUDE_SESSION_ID: 0,
|
|
138
134
|
FIREBASE_APP_INSTANCE_ID: 1,
|
|
139
|
-
AIRSHIP_CHANNEL_ID: 2
|
|
135
|
+
AIRSHIP_CHANNEL_ID: 2,
|
|
136
|
+
BATCH_INSTALLATION_ID: 3
|
|
140
137
|
}
|
|
141
138
|
|
|
142
139
|
exports.PurchaseResult = {
|
|
@@ -160,3 +157,22 @@ exports.PlanType = {
|
|
|
160
157
|
nonRenewingSubscription: 3,
|
|
161
158
|
unknown: 4
|
|
162
159
|
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
exports.RunningMode = {
|
|
163
|
+
transactionOnly: 0,
|
|
164
|
+
observer: 1,
|
|
165
|
+
paywallOnly: 2,
|
|
166
|
+
paywallObserver: 3,
|
|
167
|
+
full: 4
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
exports.PaywallAction = {
|
|
171
|
+
close: 'close',
|
|
172
|
+
login: 'login',
|
|
173
|
+
navigate: 'navigate',
|
|
174
|
+
purchase: 'purchase',
|
|
175
|
+
restore: 'restore',
|
|
176
|
+
open_presentation: 'open_presentation',
|
|
177
|
+
promo_code: 'promo_code',
|
|
178
|
+
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="RunConfigurationProducerService">
|
|
4
|
-
<option name="ignoredProducers">
|
|
5
|
-
<set>
|
|
6
|
-
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
|
7
|
-
</set>
|
|
8
|
-
</option>
|
|
9
|
-
</component>
|
|
10
|
-
</project>
|