@purchasely/cordova-plugin-purchasely 2.3.2 → 4.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/example/android.sh +8 -0
- package/example/config.xml +1 -1
- package/example/ios.sh +16 -0
- package/example/package-lock.json +426 -477
- package/example/package.json +5 -4
- package/example/www/index.html +12 -0
- package/example/www/js/index.js +114 -10
- package/package.json +9 -1
- package/plugin.xml +16 -5
- package/purchasely.iml +11 -0
- package/src/android/PLYProductActivity.kt +171 -0
- package/src/android/PLYSubscriptionsActivity.java +1 -1
- package/src/android/PurchaselyPlugin.kt +925 -0
- package/src/android/activity_ply_product_activity.xml +2 -2
- package/src/android/activity_ply_subscriptions_activity.xml +6 -0
- package/src/ios/CDVPurchasely.h +24 -6
- package/src/ios/CDVPurchasely.m +441 -37
- package/src/ios/Hybrid/PLYPlan+Hybrid.m +0 -1
- package/src/ios/Hybrid/PLYPresentationPlan+Hybrid.h +20 -0
- package/src/ios/Hybrid/PLYPresentationPlan+Hybrid.m +31 -0
- package/src/ios/Hybrid/Purchasely_Hybrid.h +1 -0
- package/src/ios/Hybrid/UIColor+PLYHelper.h +19 -0
- package/src/ios/Hybrid/UIColor+PLYHelper.m +66 -0
- package/www/Purchasely.js +101 -28
- package/src/android/PLYProductActivity.java +0 -87
- package/src/android/PurchaselyPlugin.java +0 -739
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PLYHelper+NSColor.h
|
|
3
|
+
// Purchasely
|
|
4
|
+
//
|
|
5
|
+
// Created by Jean-François GRANG on 21/12/2022.
|
|
6
|
+
// Copyright © 2022 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <UIKit/UIKit.h>
|
|
10
|
+
|
|
11
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
12
|
+
|
|
13
|
+
@interface UIColor (PLYHelper)
|
|
14
|
+
|
|
15
|
+
+ (UIColor * _Nullable)ply_fromHex:(NSString *)hex;
|
|
16
|
+
|
|
17
|
+
@end
|
|
18
|
+
|
|
19
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NSColor+PLYHelper.m
|
|
3
|
+
// Purchasely
|
|
4
|
+
//
|
|
5
|
+
// Created by Jean-François GRANG on 21/12/2022.
|
|
6
|
+
// Copyright © 2022 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
#import "UIColor+PLYHelper.h"
|
|
11
|
+
|
|
12
|
+
@implementation UIColor (PLYHelper)
|
|
13
|
+
|
|
14
|
+
+ (UIColor * _Nullable)ply_fromHex:(NSString *)hex {
|
|
15
|
+
|
|
16
|
+
NSString *cString = [hex stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
|
|
17
|
+
|
|
18
|
+
if ([cString length] == 0) {
|
|
19
|
+
return nil;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if ([cString characterAtIndex:0] == '#') {
|
|
23
|
+
cString = [cString substringFromIndex:1];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (cString.length != 6 && cString.length != 8) {
|
|
27
|
+
return nil;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
unsigned colorCode = 0;
|
|
31
|
+
unsigned char redByte, greenByte, blueByte, alphaByte;
|
|
32
|
+
|
|
33
|
+
NSScanner* scanner = [NSScanner scannerWithString:cString];
|
|
34
|
+
(void) [scanner scanHexInt:&colorCode];
|
|
35
|
+
|
|
36
|
+
if (cString.length == 6) {
|
|
37
|
+
redByte = (unsigned char)(colorCode >> 16);
|
|
38
|
+
greenByte = (unsigned char)(colorCode >> 8);
|
|
39
|
+
blueByte = (unsigned char)(colorCode);
|
|
40
|
+
|
|
41
|
+
return [UIColor
|
|
42
|
+
colorWithRed:(CGFloat)redByte / 0xff
|
|
43
|
+
green:(CGFloat)greenByte / 0xff
|
|
44
|
+
blue:(CGFloat)blueByte / 0xff
|
|
45
|
+
alpha:1.0];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (cString.length == 8) {
|
|
49
|
+
redByte = (unsigned char)(colorCode >> 24);
|
|
50
|
+
greenByte = (unsigned char)(colorCode >> 16);
|
|
51
|
+
blueByte = (unsigned char)(colorCode >> 8);
|
|
52
|
+
alphaByte = (unsigned char)(colorCode);
|
|
53
|
+
|
|
54
|
+
return [UIColor
|
|
55
|
+
colorWithRed:(CGFloat)redByte / 0xff
|
|
56
|
+
green:(CGFloat)greenByte / 0xff
|
|
57
|
+
blue:(CGFloat)blueByte / 0xff
|
|
58
|
+
alpha:(CGFloat)alphaByte / 0xff];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
return nil;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@end
|
package/www/Purchasely.js
CHANGED
|
@@ -2,12 +2,12 @@ var exec = require('cordova/exec');
|
|
|
2
2
|
|
|
3
3
|
var defaultError = (e) => { console.log(e); }
|
|
4
4
|
|
|
5
|
-
exports.
|
|
5
|
+
exports.start = function (apiKey, stores, storekit1, userId, logLevel, runningMode, success, error) {
|
|
6
6
|
var cordovaSdkVersion = cordova.define.moduleMap['cordova/plugin_list'].exports['metadata']['cordova-plugin-purchasely']
|
|
7
7
|
if(!cordovaSdkVersion) {
|
|
8
|
-
cordovaSdkVersion = "2.
|
|
8
|
+
cordovaSdkVersion = "4.2.0";
|
|
9
9
|
}
|
|
10
|
-
exec(success, error, 'Purchasely', '
|
|
10
|
+
exec(success, error, 'Purchasely', 'start', [apiKey, stores, storekit1, userId, logLevel, runningMode, cordovaSdkVersion]);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
exports.addEventsListener = function (success, error) {
|
|
@@ -38,8 +38,8 @@ exports.setAttribute = function (attribute, value) {
|
|
|
38
38
|
exec(() => {}, defaultError, 'Purchasely', 'setAttribute', [attribute, value]);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
exports.
|
|
42
|
-
exec(() => {}, defaultError, 'Purchasely', '
|
|
41
|
+
exports.readyToOpenDeeplink = function (isReady) {
|
|
42
|
+
exec(() => {}, defaultError, 'Purchasely', 'readyToOpenDeeplink', [isReady]);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
exports.setDefaultPresentationResultHandler = function (success, error) {
|
|
@@ -66,16 +66,24 @@ exports.presentPlanWithIdentifier = function (planId, presentationId, contentId,
|
|
|
66
66
|
exec(success, error, 'Purchasely', 'presentPlanWithIdentifier', [planId, presentationId, contentId, isFullscreen]);
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
exports.
|
|
70
|
-
exec(
|
|
69
|
+
exports.fetchPresentation = function (presentationId, contentId, success, error) {
|
|
70
|
+
exec(success, error, 'Purchasely', 'fetchPresentation', [null, presentationId, contentId]);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.fetchPresentationForPlacement = function (placementId, contentId, success, error) {
|
|
74
|
+
exec(success, error, 'Purchasely', 'fetchPresentation', [placementId, null, contentId]);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
exports.presentPresentation = function (presentation, isFullscreen, backgroundColor,success, error) {
|
|
78
|
+
exec(success, error, 'Purchasely', 'presentPresentation', [presentation, isFullscreen, backgroundColor]);
|
|
71
79
|
};
|
|
72
80
|
|
|
73
|
-
exports.
|
|
74
|
-
exec(
|
|
81
|
+
exports.presentSubscriptions = function () {
|
|
82
|
+
exec(() => {}, defaultError, 'Purchasely', 'presentSubscriptions', []);
|
|
75
83
|
};
|
|
76
84
|
|
|
77
|
-
exports.purchaseWithPlanVendorId = function (planId, success, error) {
|
|
78
|
-
exec( success, error, 'Purchasely', 'purchaseWithPlanVendorId', [planId,
|
|
85
|
+
exports.purchaseWithPlanVendorId = function (planId, offerId, contentId, success, error) {
|
|
86
|
+
exec( success, error, 'Purchasely', 'purchaseWithPlanVendorId', [planId, offerId, contentId]);
|
|
79
87
|
};
|
|
80
88
|
|
|
81
89
|
exports.restoreAllProducts = function (success, error) {
|
|
@@ -90,8 +98,8 @@ exports.purchasedSubscription = function (success, error) {
|
|
|
90
98
|
exec(success, error, 'Purchasely', 'purchasedSubscription', []);
|
|
91
99
|
};
|
|
92
100
|
|
|
93
|
-
exports.
|
|
94
|
-
exec(success, error, 'Purchasely', '
|
|
101
|
+
exports.isDeeplinkHandled = function (deepLink, success, error) {
|
|
102
|
+
exec(success, error, 'Purchasely', 'isDeeplinkHandled', [deepLink]);
|
|
95
103
|
};
|
|
96
104
|
|
|
97
105
|
exports.allProducts = function (success, error) {
|
|
@@ -114,10 +122,6 @@ exports.onProcessAction = function (processAction) {
|
|
|
114
122
|
exec(() => {}, defaultError, 'Purchasely', 'onProcessAction', [processAction]);
|
|
115
123
|
};
|
|
116
124
|
|
|
117
|
-
exports.closePaywall = function () {
|
|
118
|
-
exec(() => {}, defaultError, 'Purchasely', 'closePaywall', []);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
125
|
exports.userDidConsumeSubscriptionContent = function () {
|
|
122
126
|
exec(() => {}, defaultError, 'Purchasely', 'userDidConsumeSubscriptionContent', []);
|
|
123
127
|
};
|
|
@@ -130,6 +134,62 @@ exports.setLanguage = function (language) {
|
|
|
130
134
|
exec(() => {}, defaultError, 'Purchasely', 'setLanguage', [language]);
|
|
131
135
|
};
|
|
132
136
|
|
|
137
|
+
exports.showPresentation = function () {
|
|
138
|
+
exec(() => {}, defaultError, 'Purchasely', 'showPresentation', []);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
exports.hidePresentation = function () {
|
|
142
|
+
exec(() => {}, defaultError, 'Purchasely', 'hidePresentation', []);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
exports.closePresentation = function () {
|
|
146
|
+
exec(() => {}, defaultError, 'Purchasely', 'closePresentation', []);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
exports.setUserAttributeWithString = function (key, value) {
|
|
150
|
+
exec(() => {}, defaultError, 'Purchasely', 'setUserAttributeWithString', [key, value]);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
exports.setUserAttributeWithBoolean = function (key, value) {
|
|
154
|
+
exec(() => {}, defaultError, 'Purchasely', 'setUserAttributeWithBoolean', [key, value]);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
exports.setUserAttributeWithInt = function (key, value) {
|
|
158
|
+
exec(() => {}, defaultError, 'Purchasely', 'setUserAttributeWithInt', [key, value]);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
exports.setUserAttributeWithDouble = function (key, value) {
|
|
162
|
+
exec(() => {}, defaultError, 'Purchasely', 'setUserAttributeWithDouble', [key, value]);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
exports.setUserAttributeWithDate = function (key, value) {
|
|
166
|
+
exec(() => {}, defaultError, 'Purchasely', 'setUserAttributeWithDate', [key, value]);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
exports.userAttribute = function (key, success, error) {
|
|
170
|
+
exec(success, error, 'Purchasely', 'userAttribute', [key]);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
exports.clearUserAttribute = function (key) {
|
|
174
|
+
exec(() => {}, defaultError, 'Purchasely', 'clearUserAttribute', [key]);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
exports.clearUserAttributes = function () {
|
|
178
|
+
exec(() => {}, defaultError, 'Purchasely', 'clearUserAttributes', []);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
exports.isEligibleForIntroOffer = function (planId, success, error) {
|
|
182
|
+
exec(success, error, 'Purchasely', 'isEligibleForIntroOffer', [planId]);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
exports.signPromotionalOffer = function (storeProductId, storeOfferId, success, error) {
|
|
186
|
+
exec(success, error, 'Purchasely', 'signPromotionalOffer', [storeProductId, storeOfferId]);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
exports.setThemeMode = function (mode) {
|
|
190
|
+
exec(() => {}, defaultError, 'Purchasely', 'setThemeMode', [mode]);
|
|
191
|
+
};
|
|
192
|
+
|
|
133
193
|
exports.LogLevel = {
|
|
134
194
|
DEBUG: 0,
|
|
135
195
|
INFO: 1,
|
|
@@ -138,9 +198,9 @@ exports.LogLevel = {
|
|
|
138
198
|
}
|
|
139
199
|
|
|
140
200
|
exports.Attribute = {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
201
|
+
FIREBASE_APP_INSTANCE_ID: 0,
|
|
202
|
+
AIRSHIP_CHANNEL_ID: 1,
|
|
203
|
+
AIRSHIP_USER_ID: 2,
|
|
144
204
|
BATCH_INSTALLATION_ID: 3,
|
|
145
205
|
ADJUST_ID: 4,
|
|
146
206
|
APPSFLYER_ID: 5,
|
|
@@ -148,9 +208,18 @@ exports.Attribute = {
|
|
|
148
208
|
MIXPANEL_DISTINCT_ID: 7,
|
|
149
209
|
CLEVER_TAP_ID: 8,
|
|
150
210
|
SENDINBLUE_USER_EMAIL: 9,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
AT_INTERNET_ID_CLIENT: 12
|
|
211
|
+
ITERABLE_USER_EMAIL: 10,
|
|
212
|
+
ITERABLE_USER_ID: 11,
|
|
213
|
+
AT_INTERNET_ID_CLIENT: 12,
|
|
214
|
+
MPARTICLE_USER_ID: 13,
|
|
215
|
+
CUSTOMERIO_USER_ID: 14,
|
|
216
|
+
CUSTOMERIO_USER_EMAIL: 15,
|
|
217
|
+
BRANCH_USER_DEVELOPER_IDENTITY: 16,
|
|
218
|
+
AMPLITUDE_USER_ID: 17,
|
|
219
|
+
AMPLITUDE_DEVICE_ID: 18,
|
|
220
|
+
MOENGAGE_UNIQUE_ID: 19,
|
|
221
|
+
ONESIGNAL_EXTERNAL_ID: 20,
|
|
222
|
+
BATCH_CUSTOM_USER_ID: 21,
|
|
154
223
|
}
|
|
155
224
|
|
|
156
225
|
exports.PurchaseResult = {
|
|
@@ -177,11 +246,8 @@ exports.PlanType = {
|
|
|
177
246
|
|
|
178
247
|
|
|
179
248
|
exports.RunningMode = {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
paywallOnly: 2,
|
|
183
|
-
paywallObserver: 3,
|
|
184
|
-
full: 4
|
|
249
|
+
paywallObserver: 2,
|
|
250
|
+
full: 3
|
|
185
251
|
}
|
|
186
252
|
|
|
187
253
|
exports.PaywallAction = {
|
|
@@ -191,5 +257,12 @@ exports.PaywallAction = {
|
|
|
191
257
|
purchase: 'purchase',
|
|
192
258
|
restore: 'restore',
|
|
193
259
|
open_presentation: 'open_presentation',
|
|
260
|
+
open_presentation: 'open_placement',
|
|
194
261
|
promo_code: 'promo_code',
|
|
195
262
|
}
|
|
263
|
+
|
|
264
|
+
exports.ThemeMode = {
|
|
265
|
+
light: 0,
|
|
266
|
+
dark: 1,
|
|
267
|
+
system: 2
|
|
268
|
+
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
package cordova.plugin.purchasely;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.content.Intent;
|
|
5
|
-
import android.os.Bundle;
|
|
6
|
-
|
|
7
|
-
import androidx.annotation.Nullable;
|
|
8
|
-
import androidx.appcompat.app.AppCompatActivity;
|
|
9
|
-
import androidx.core.view.WindowCompat;
|
|
10
|
-
import androidx.fragment.app.Fragment;
|
|
11
|
-
|
|
12
|
-
import java.lang.ref.WeakReference;
|
|
13
|
-
|
|
14
|
-
import io.purchasely.ext.ProductViewResultListener;
|
|
15
|
-
import io.purchasely.ext.Purchasely;
|
|
16
|
-
|
|
17
|
-
public class PLYProductActivity extends AppCompatActivity {
|
|
18
|
-
|
|
19
|
-
@Override
|
|
20
|
-
protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
|
21
|
-
super.onCreate(savedInstanceState);
|
|
22
|
-
|
|
23
|
-
boolean isFullScreen = getIntent().getExtras().getBoolean("isFullScreen");
|
|
24
|
-
if(isFullScreen) {
|
|
25
|
-
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
String package_name = getApplication().getPackageName();
|
|
29
|
-
setContentView(getApplication().getResources()
|
|
30
|
-
.getIdentifier("activity_ply_product_activity",
|
|
31
|
-
"layout",
|
|
32
|
-
package_name)
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
String presentationId = getIntent().getExtras().getString("presentationId");
|
|
36
|
-
String placementId = getIntent().getExtras().getString("placementId");
|
|
37
|
-
String productId = getIntent().getExtras().getString("productId");
|
|
38
|
-
String planId = getIntent().getExtras().getString("planId");
|
|
39
|
-
String contentId = getIntent().getExtras().getString("contentId");
|
|
40
|
-
|
|
41
|
-
Fragment fragment;
|
|
42
|
-
if(placementId != null && !placementId.isEmpty()) {
|
|
43
|
-
fragment = Purchasely.presentationFragmentForPlacement(placementId, contentId, null, listener);
|
|
44
|
-
} else if(planId != null && !planId.isEmpty()) {
|
|
45
|
-
fragment = Purchasely.planFragment(planId, presentationId, contentId, null, listener);
|
|
46
|
-
} else if(productId != null && !productId.isEmpty()) {
|
|
47
|
-
fragment = Purchasely.productFragment(productId, presentationId, contentId, null, listener);
|
|
48
|
-
} else {
|
|
49
|
-
fragment = Purchasely.presentationFragment(presentationId, contentId, null, listener);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if(fragment == null) {
|
|
53
|
-
supportFinishAfterTransition();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
getSupportFragmentManager().beginTransaction()
|
|
58
|
-
.replace(getApplication().getResources()
|
|
59
|
-
.getIdentifier("fragmentContainer",
|
|
60
|
-
"id",
|
|
61
|
-
package_name), fragment)
|
|
62
|
-
.commit();
|
|
63
|
-
|
|
64
|
-
PurchaselyPlugin.ProductActivity productActivity = new PurchaselyPlugin.ProductActivity();
|
|
65
|
-
productActivity.presentationId = presentationId;
|
|
66
|
-
productActivity.placementId = placementId;
|
|
67
|
-
productActivity.productId = productId;
|
|
68
|
-
productActivity.planId = planId;
|
|
69
|
-
productActivity.contentId = contentId;
|
|
70
|
-
productActivity.activity = new WeakReference<>(this);
|
|
71
|
-
PurchaselyPlugin.productActivity = productActivity;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
@Override
|
|
75
|
-
protected void onDestroy() {
|
|
76
|
-
PurchaselyPlugin.productActivity.activity = null;
|
|
77
|
-
super.onDestroy();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
ProductViewResultListener listener = PurchaselyPlugin::sendPurchaseResult;
|
|
81
|
-
|
|
82
|
-
static Intent newIntent(Activity activity) {
|
|
83
|
-
Intent intent = new Intent(activity, PLYProductActivity.class);
|
|
84
|
-
//intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
|
85
|
-
return intent;
|
|
86
|
-
}
|
|
87
|
-
}
|