@purchasely/cordova-plugin-purchasely 2.3.1 → 4.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.
@@ -0,0 +1,20 @@
1
+ //
2
+ // PLYPresentationPlan+Hybrid.h
3
+ // Pods
4
+ //
5
+ // Created by Florian Huet on 29/09/2023.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <Purchasely/Purchasely-Swift.h>
10
+ //@import Purchasely;
11
+
12
+ NS_ASSUME_NONNULL_BEGIN
13
+
14
+ @interface PLYPresentationPlan (Hybrid)
15
+
16
+ - (NSDictionary *)asDictionary;
17
+
18
+ @end
19
+
20
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,31 @@
1
+ //
2
+ // PLYPresentationPlan+Hybrid.m
3
+ // react-native-purchasely
4
+ //
5
+ // Created by Florian Huet on 29/09/2023.
6
+ //
7
+
8
+ #import "PLYPresentationPlan+Hybrid.h"
9
+ #import <Foundation/Foundation.h>
10
+
11
+ @implementation PLYPresentationPlan (Hybrid)
12
+
13
+ - (NSDictionary *)asDictionary {
14
+ NSMutableDictionary<NSString *, NSObject *> *dict = [NSMutableDictionary new];
15
+
16
+ if (self.offerId) {
17
+ [dict setObject:self.offerId forKey:@"offerId"];
18
+ }
19
+
20
+ if (self.storeProductId) {
21
+ [dict setObject:self.storeProductId forKey:@"storeProductId"];
22
+ }
23
+
24
+ if (self.planVendorId) {
25
+ [dict setObject:self.planVendorId forKey:@"planVendorId"];
26
+ }
27
+
28
+ return dict;
29
+ }
30
+
31
+ @end
@@ -11,6 +11,7 @@
11
11
  #import "PLYPlan+Hybrid.h"
12
12
  #import "PLYProduct+Hybrid.h"
13
13
  #import "PLYSubscription+Hybrid.h"
14
+ #import "PLYPresentationPlan+Hybrid.h"
14
15
  #import "UIViewController+Hybrid.h"
15
16
 
16
17
  #endif /* Purchasely_Hybrid_h */
@@ -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.startWithAPIKey = function (apiKey, stores, userId, logLevel, runningMode, success, error) {
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.3.0" //fallback if we cannot find version from metadata
8
+ cordovaSdkVersion = "4.1.0" //fallback if we cannot find version from metadata
9
9
  }
10
- exec(success, error, 'Purchasely', 'startWithAPIKey', [apiKey, stores, userId, logLevel, runningMode, cordovaSdkVersion]);
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.isReadyToPurchase = function (isReady) {
42
- exec(() => {}, defaultError, 'Purchasely', 'isReadyToPurchase', [isReady]);
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.presentSubscriptions = function () {
70
- exec(() => {}, defaultError, 'Purchasely', 'presentSubscriptions', []);
69
+ exports.fetchPresentation = function (presentationId, contentId, success, error) {
70
+ exec(success, error, 'Purchasely', 'fetchPresentation', [null, presentationId, contentId]);
71
71
  };
72
72
 
73
- exports.purchaseWithPlanVendorId = function (planId, contentId, success, error) {
74
- exec( success, error, 'Purchasely', 'purchaseWithPlanVendorId', [planId, contentId]);
73
+ exports.fetchPresentationForPlacement = function (placementId, contentId, success, error) {
74
+ exec(success, error, 'Purchasely', 'fetchPresentation', [placementId, null, contentId]);
75
75
  };
76
76
 
77
- exports.purchaseWithPlanVendorId = function (planId, success, error) {
78
- exec( success, error, 'Purchasely', 'purchaseWithPlanVendorId', [planId, null]);
77
+ exports.presentPresentation = function (presentation, isFullscreen, backgroundColor,success, error) {
78
+ exec(success, error, 'Purchasely', 'presentPresentation', [presentation, isFullscreen, backgroundColor]);
79
+ };
80
+
81
+ exports.presentSubscriptions = function () {
82
+ exec(() => {}, defaultError, 'Purchasely', 'presentSubscriptions', []);
83
+ };
84
+
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.handle = function (deepLink, success, error) {
94
- exec(success, error, 'Purchasely', 'handle', [deepLink]);
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,58 @@ 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
+
133
189
  exports.LogLevel = {
134
190
  DEBUG: 0,
135
191
  INFO: 1,
@@ -138,9 +194,9 @@ exports.LogLevel = {
138
194
  }
139
195
 
140
196
  exports.Attribute = {
141
- AMPLITUDE_SESSION_ID: 0,
142
- FIREBASE_APP_INSTANCE_ID: 1,
143
- AIRSHIP_CHANNEL_ID: 2,
197
+ FIREBASE_APP_INSTANCE_ID: 0,
198
+ AIRSHIP_CHANNEL_ID: 1,
199
+ AIRSHIP_USER_ID: 2,
144
200
  BATCH_INSTALLATION_ID: 3,
145
201
  ADJUST_ID: 4,
146
202
  APPSFLYER_ID: 5,
@@ -148,9 +204,17 @@ exports.Attribute = {
148
204
  MIXPANEL_DISTINCT_ID: 7,
149
205
  CLEVER_TAP_ID: 8,
150
206
  SENDINBLUE_USER_EMAIL: 9,
151
- ITERABLE_USER_ID: 10,
152
- ITERABLE_USER_EMAIL: 11,
153
- AT_INTERNET_ID_CLIENT: 12
207
+ ITERABLE_USER_EMAIL: 10,
208
+ ITERABLE_USER_ID: 11,
209
+ AT_INTERNET_ID_CLIENT: 12,
210
+ MPARTICLE_USER_ID: 13,
211
+ CUSTOMERIO_USER_ID: 14,
212
+ CUSTOMERIO_USER_EMAIL: 15,
213
+ BRANCH_USER_DEVELOPER_IDENTITY: 16,
214
+ AMPLITUDE_USER_ID: 17,
215
+ AMPLITUDE_DEVICE_ID: 18,
216
+ MOENGAGE_UNIQUE_ID: 19,
217
+ ONESIGNAL_EXTERNAL_ID: 20
154
218
  }
155
219
 
156
220
  exports.PurchaseResult = {
@@ -177,11 +241,8 @@ exports.PlanType = {
177
241
 
178
242
 
179
243
  exports.RunningMode = {
180
- transactionOnly: 0,
181
- observer: 1,
182
- paywallOnly: 2,
183
- paywallObserver: 3,
184
- full: 4
244
+ paywallObserver: 2,
245
+ full: 3
185
246
  }
186
247
 
187
248
  exports.PaywallAction = {
@@ -191,5 +252,6 @@ exports.PaywallAction = {
191
252
  purchase: 'purchase',
192
253
  restore: 'restore',
193
254
  open_presentation: 'open_presentation',
255
+ open_presentation: 'open_placement',
194
256
  promo_code: 'promo_code',
195
257
  }
@@ -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
- }