@purchasely/cordova-plugin-purchasely 1.2.0 → 2.1.1
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 +247 -75
- package/example/package.json +4 -3
- package/example/www/js/index.js +60 -16
- 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 +131 -70
- 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 +188 -89
- package/src/ios/Hybrid/PLYPlan+Hybrid.m +9 -0
- package/www/Purchasely.js +35 -28
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<resources>
|
|
2
|
+
<style name="Theme.Purchasely.Fullscreen" parent="Theme.AppCompat.Light.NoActionBar">
|
|
3
|
+
<item name="android:navigationBarColor">@android:color/transparent</item>
|
|
4
|
+
<item name="android:statusBarColor">@android:color/transparent</item>
|
|
5
|
+
</style>
|
|
6
|
+
</resources>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<resources>
|
|
2
|
+
<style name="Theme.Purchasely.Fullscreen" parent="Theme.AppCompat.Light.NoActionBar">
|
|
3
|
+
<item name="android:navigationBarColor">@android:color/transparent</item>
|
|
4
|
+
<item name="android:statusBarColor">@android:color/transparent</item>
|
|
5
|
+
</style>
|
|
6
|
+
</resources>
|
|
@@ -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 {
|
|
@@ -263,50 +310,6 @@
|
|
|
263
310
|
[Purchasely setLanguageFrom:locale];
|
|
264
311
|
}
|
|
265
312
|
|
|
266
|
-
- (void)setLoginTappedHandler:(CDVInvokedUrlCommand*)command {
|
|
267
|
-
self.loginTappedCommand = command;
|
|
268
|
-
[Purchasely setLoginTappedHandler:^(UIViewController * _Nonnull controller, void (^ _Nonnull closedHandler)(BOOL)) {
|
|
269
|
-
self.loginClosedHandler = closedHandler;
|
|
270
|
-
|
|
271
|
-
[self.presentedPresentationViewController dismissViewControllerAnimated:true completion:^{
|
|
272
|
-
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
273
|
-
[result setKeepCallbackAsBool:YES];
|
|
274
|
-
[self.commandDelegate sendPluginResult:result callbackId:self.loginTappedCommand.callbackId];
|
|
275
|
-
}];
|
|
276
|
-
}];
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
- (void)onUserLoggedIn:(CDVInvokedUrlCommand*)command {
|
|
280
|
-
BOOL userDidLogin = [[command argumentAtIndex:0] boolValue];
|
|
281
|
-
|
|
282
|
-
[Purchasely showController:self.presentedPresentationViewController type: PLYUIControllerTypeProductPage];
|
|
283
|
-
self.loginClosedHandler(userDidLogin);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
- (void)setConfirmPurchaseHandler:(CDVInvokedUrlCommand*)command {
|
|
287
|
-
self.authorizePurchaseCommand = command;
|
|
288
|
-
[Purchasely setConfirmPurchaseHandler:^(UIViewController * _Nonnull controller, void (^ _Nonnull authorizePurchaseHandler)(BOOL)) {
|
|
289
|
-
self.authorizePurchaseHandler = authorizePurchaseHandler;
|
|
290
|
-
|
|
291
|
-
[self.presentedPresentationViewController dismissViewControllerAnimated:true completion:^{
|
|
292
|
-
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
293
|
-
[result setKeepCallbackAsBool:YES];
|
|
294
|
-
[self.commandDelegate sendPluginResult:result callbackId:self.authorizePurchaseCommand.callbackId];
|
|
295
|
-
}];
|
|
296
|
-
}];
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
- (void)processToPayment:(CDVInvokedUrlCommand*)command {
|
|
300
|
-
BOOL processToPayment = [[command argumentAtIndex:0] boolValue];
|
|
301
|
-
|
|
302
|
-
if (self.presentedPresentationViewController != nil) {
|
|
303
|
-
[Purchasely showController:self.presentedPresentationViewController type: PLYUIControllerTypeProductPage];
|
|
304
|
-
if (self.authorizePurchaseHandler != nil) {
|
|
305
|
-
self.authorizePurchaseHandler(processToPayment);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
313
|
// Helpers
|
|
311
314
|
|
|
312
315
|
- (NSDictionary<NSString *, NSObject *> *) resultDictionaryForPresentationController:(PLYProductViewControllerResult)result plan:(PLYPlan * _Nullable)plan {
|
|
@@ -333,6 +336,102 @@
|
|
|
333
336
|
return productViewResult;
|
|
334
337
|
}
|
|
335
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
|
+
|
|
336
435
|
- (void)successFor:(CDVInvokedUrlCommand *)command {
|
|
337
436
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
338
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 () {
|
|
@@ -110,20 +102,16 @@ exports.productWithIdentifier = function (productId, success) {
|
|
|
110
102
|
exec(success, defaultError, 'Purchasely', 'productWithIdentifier', [productId]);
|
|
111
103
|
};
|
|
112
104
|
|
|
113
|
-
exports.
|
|
114
|
-
exec(success, defaultError, 'Purchasely', '
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
exports.onUserLoggedIn = function (userLoggedIn) {
|
|
118
|
-
exec(() => {}, defaultError, 'Purchasely', 'onUserLoggedIn', [userLoggedIn]);
|
|
105
|
+
exports.setPaywallActionInterceptor = function (success) {
|
|
106
|
+
exec(success, defaultError, 'Purchasely', 'setPaywallActionInterceptor', []);
|
|
119
107
|
};
|
|
120
108
|
|
|
121
|
-
exports.
|
|
122
|
-
exec(
|
|
109
|
+
exports.onProcessAction = function (processAction) {
|
|
110
|
+
exec(() => {}, defaultError, 'Purchasely', 'onProcessAction', [processAction]);
|
|
123
111
|
};
|
|
124
112
|
|
|
125
|
-
exports.
|
|
126
|
-
exec(() => {}, defaultError, 'Purchasely', '
|
|
113
|
+
exports.closePaywall = function () {
|
|
114
|
+
exec(() => {}, defaultError, 'Purchasely', 'closePaywall', []);
|
|
127
115
|
};
|
|
128
116
|
|
|
129
117
|
exports.userSubscriptions = function (success, error) {
|
|
@@ -169,3 +157,22 @@ exports.PlanType = {
|
|
|
169
157
|
nonRenewingSubscription: 3,
|
|
170
158
|
unknown: 4
|
|
171
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
|
+
}
|