@purchasely/cordova-plugin-purchasely 1.1.6 → 1.2.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/VERSIONS.md CHANGED
@@ -10,3 +10,8 @@ This file provides the underlying native SDK versions that the Cordova SDK relie
10
10
  | 1.1.1 | 2.7.3 | 2.7.2 |
11
11
  | 1.1.2 | 2.7.3 | 2.7.2 |
12
12
  | 1.1.3 | 2.7.3 | 2.7.2 |
13
+ | 1.1.6 | 2.7.3 | 2.7.3 |
14
+ | 1.1.7 | 2.7.3 | 2.7.4 |
15
+ | 1.1.8 | 2.7.3 | 2.7.6 |
16
+ | 1.2.0 | 2.8.0 | 2.8.0 |
17
+ | 1.2.1 | 2.8.0 | 2.8.0 |
@@ -9,15 +9,15 @@
9
9
  "version": "1.0.0",
10
10
  "license": "Apache-2.0",
11
11
  "devDependencies": {
12
- "@purchasely/cordova-plugin-purchasely": "file:..",
13
12
  "cordova-android": "^10.1.1",
14
13
  "cordova-ios": "^6.2.0",
14
+ "cordova-plugin-purchasely": "file:..",
15
15
  "cordova-plugin-whitelist": "^1.3.5"
16
16
  }
17
17
  },
18
18
  "..": {
19
- "name": "@purchasely/cordova-plugin-purchasely",
20
- "version": "1.1.6",
19
+ "name": "cordova-plugin-purchasely",
20
+ "version": "1.2.0",
21
21
  "dev": true,
22
22
  "license": "ISC"
23
23
  },
@@ -67,10 +67,6 @@
67
67
  "node": ">= 8"
68
68
  }
69
69
  },
70
- "node_modules/@purchasely/cordova-plugin-purchasely": {
71
- "resolved": "..",
72
- "link": true
73
- },
74
70
  "node_modules/abbrev": {
75
71
  "version": "1.1.1",
76
72
  "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -285,6 +281,10 @@
285
281
  "node": ">=10"
286
282
  }
287
283
  },
284
+ "node_modules/cordova-plugin-purchasely": {
285
+ "resolved": "..",
286
+ "link": true
287
+ },
288
288
  "node_modules/cordova-plugin-whitelist": {
289
289
  "version": "1.3.5",
290
290
  "resolved": "https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.5.tgz",
@@ -1200,9 +1200,6 @@
1200
1200
  "fastq": "^1.6.0"
1201
1201
  }
1202
1202
  },
1203
- "@purchasely/cordova-plugin-purchasely": {
1204
- "version": "file:.."
1205
- },
1206
1203
  "abbrev": {
1207
1204
  "version": "1.1.1",
1208
1205
  "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -1377,6 +1374,9 @@
1377
1374
  "xml-escape": "^1.1.0"
1378
1375
  }
1379
1376
  },
1377
+ "cordova-plugin-purchasely": {
1378
+ "version": "file:.."
1379
+ },
1380
1380
  "cordova-plugin-whitelist": {
1381
1381
  "version": "1.3.5",
1382
1382
  "resolved": "https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.5.tgz",
@@ -13,19 +13,19 @@
13
13
  "author": "Apache Cordova Team",
14
14
  "license": "Apache-2.0",
15
15
  "devDependencies": {
16
- "@purchasely/cordova-plugin-purchasely": "file:..",
17
16
  "cordova-android": "^10.1.1",
18
17
  "cordova-ios": "^6.2.0",
18
+ "cordova-plugin-purchasely": "file:..",
19
19
  "cordova-plugin-whitelist": "^1.3.5"
20
20
  },
21
21
  "cordova": {
22
22
  "plugins": {
23
23
  "cordova-plugin-whitelist": {},
24
- "@purchasley/cordova-plugin-purchasely": {}
24
+ "cordova-plugin-purchasely": {}
25
25
  },
26
26
  "platforms": [
27
27
  "ios",
28
28
  "android"
29
29
  ]
30
30
  }
31
- }
31
+ }
@@ -59,6 +59,9 @@
59
59
  <div style="margin-top: 20px;">
60
60
  <button id="restore">Restore</button>
61
61
  </div>
62
+ <div style="margin-top: 20px;">
63
+ <button id="silentRestore">Silent restore</button>
64
+ </div>
62
65
  <div style="margin-top: 20px;">
63
66
  <button id="openDeeplink">Deeplink</button>
64
67
  </div>
@@ -29,6 +29,8 @@ function onDeviceReady() {
29
29
 
30
30
  console.log("Hi");
31
31
 
32
+ Purchasely.setLanguage('en')
33
+
32
34
  Purchasely.startWithAPIKey(
33
35
  'afa96c76-1d8e-4e3c-a48f-204a3cd93a15',
34
36
  ['Google'],
@@ -46,6 +48,7 @@ function onDeviceReady() {
46
48
  document.getElementById("presentSubscriptions").addEventListener("click", presentSubscriptions);
47
49
  document.getElementById("purchaseWithPlanVendorId").addEventListener("click", purchaseWithPlanVendorId);
48
50
  document.getElementById("restore").addEventListener("click", restore);
51
+ document.getElementById("silentRestore").addEventListener("click", silentRestore);
49
52
  document.getElementById("processToPayment").addEventListener("click", processToPayment);
50
53
 
51
54
  }
@@ -81,6 +84,7 @@ function onPuchaselySdkReady() {
81
84
  Purchasely.setLogLevel(Purchasely.LogLevel.DEBUG);
82
85
 
83
86
  Purchasely.setAttribute(Purchasely.Attribute.FIREBASE_APP_INSTANCE_ID, "1");
87
+ Purchasely.setAttribute(Purchasely.Attribute.BATCH_INSTALLATION_ID, "testBatch1");
84
88
 
85
89
  Purchasely.isReadyToPurchase(true);
86
90
 
@@ -151,6 +155,18 @@ function restore() {
151
155
  );
152
156
  }
153
157
 
158
+ function silentRestore() {
159
+ Purchasely.silentRestoreAllProducts(
160
+ (plan) => {
161
+ if(plan) console.log("Silent restore " + plan.vendorId);
162
+ else console.log("Nothing to restore");
163
+ },
164
+ (error) => {
165
+ console.log("Silent Restore failed " + error);
166
+ },
167
+ );
168
+ }
169
+
154
170
  function openDeeplink() {
155
171
  Purchasely.handle(
156
172
  "purchasely://ply/presentations/CAROUSEL",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purchasely/cordova-plugin-purchasely",
3
- "version": "1.1.6",
3
+ "version": "1.2.1",
4
4
  "description": "Purchasely is a solution to ease the integration and boost your In-App Purchases & Subscriptions on the App Store, Google Play Store, Amazon Appstore and Huawei App Gallery.",
5
5
  "cordova": {
6
6
  "id": "@purchasely/cordova-plugin-purchasely",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="@purchasely/cordova-plugin-purchasely" version="1.1.6" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <plugin id="@purchasely/cordova-plugin-purchasely" version="1.2.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
3
3
  <name>Purchasely</name>
4
4
  <js-module name="Purchasely" src="www/Purchasely.js">
5
5
  <clobbers target="Purchasely" />
@@ -28,7 +28,7 @@
28
28
  <source url="https://github.com/CocoaPods/Specs.git"/>
29
29
  </config>
30
30
  <pods use-frameworks="true">
31
- <pod name="Purchasely" spec="2.7.3"/>
31
+ <pod name="Purchasely" spec="2.8.0"/>
32
32
  </pods>
33
33
  </podspec>
34
34
  </platform>
@@ -51,7 +51,7 @@
51
51
  android:theme="@style/Theme.AppCompat.Light.NoActionBar">
52
52
  </activity>
53
53
  </config-file>
54
- <framework src="io.purchasely:core:2.7.3" />
54
+ <framework src="io.purchasely:core:2.8.0" />
55
55
  <source-file src="src/android/PurchaselyPlugin.java" target-dir="src/cordova/plugin/purchasely" />
56
56
  <source-file src="src/android/PLYProductActivity.java" target-dir="src/cordova/plugin/purchasely" />
57
57
  <source-file src="src/android/PLYSubscriptionsActivity.java" target-dir="src/cordova/plugin/purchasely" />
@@ -14,11 +14,13 @@ import org.jetbrains.annotations.Nullable;
14
14
  import org.json.JSONArray;
15
15
  import org.json.JSONException;
16
16
  import org.json.JSONObject;
17
+ import org.w3c.dom.Attr;
17
18
 
18
19
  import java.lang.ref.WeakReference;
19
20
  import java.util.ArrayList;
20
21
  import java.util.HashMap;
21
22
  import java.util.List;
23
+ import java.util.Locale;
22
24
  import java.util.Map;
23
25
 
24
26
  import io.purchasely.billing.Store;
@@ -59,9 +61,9 @@ public class PurchaselyPlugin extends CordovaPlugin {
59
61
  switch (action) {
60
62
  case "startWithAPIKey":
61
63
  startWithAPIKey(
62
- args.getString(0),
64
+ getStringFromJson(args.getString(0)),
63
65
  args.getJSONArray(1),
64
- args.getString(2),
66
+ getStringFromJson(args.getString(2)),
65
67
  args.getInt(3),
66
68
  args.getBoolean(4),
67
69
  callbackContext);
@@ -79,16 +81,19 @@ public class PurchaselyPlugin extends CordovaPlugin {
79
81
  getAnonymousUserId(callbackContext);
80
82
  break;
81
83
  case "userLogin":
82
- userLogin(args.getString(0), callbackContext);
84
+ userLogin(getStringFromJson(args.getString(0)), callbackContext);
83
85
  break;
84
86
  case "userLogout":
85
87
  userLogout();
86
88
  break;
89
+ case "setLanguage":
90
+ setLanguage(getStringFromJson(args.getString(0)));
91
+ break;
87
92
  case "setLogLevel":
88
93
  setLogLevel(args.getInt(0));
89
94
  break;
90
95
  case "setAttribute":
91
- setAttribute(args.getInt(0), args.getString(1));
96
+ setAttribute(args.getInt(0), getStringFromJson(args.getString(1)));
92
97
  break;
93
98
  case "setDefaultPresentationResultHandler":
94
99
  setDefaultPresentationResultHandler(callbackContext);
@@ -104,24 +109,24 @@ public class PurchaselyPlugin extends CordovaPlugin {
104
109
  break;
105
110
  case "presentPresentationWithIdentifier":
106
111
  presentPresentationWithIdentifier(
107
- args.getString(0),
108
- args.getString(1),
112
+ getStringFromJson(args.getString(0)),
113
+ getStringFromJson(args.getString(1)),
109
114
  callbackContext
110
115
  );
111
116
  break;
112
117
  case "presentProductWithIdentifier":
113
118
  presentProductWithIdentifier(
114
- args.getString(0),
115
- args.getString(1),
116
- args.getString(2),
119
+ getStringFromJson(args.getString(0)),
120
+ getStringFromJson(args.getString(1)),
121
+ getStringFromJson(args.getString(2)),
117
122
  callbackContext
118
123
  );
119
124
  break;
120
125
  case "presentPlanWithIdentifier":
121
126
  presentPlanWithIdentifier(
122
- args.getString(0),
123
- args.getString(1),
124
- args.getString(2),
127
+ getStringFromJson(args.getString(0)),
128
+ getStringFromJson(args.getString(1)),
129
+ getStringFromJson(args.getString(2)),
125
130
  callbackContext
126
131
  );
127
132
  break;
@@ -131,25 +136,28 @@ public class PurchaselyPlugin extends CordovaPlugin {
131
136
  case "restoreAllProducts":
132
137
  restoreAllProducts(callbackContext);
133
138
  break;
139
+ case "silentRestoreAllProducts":
140
+ restoreAllProducts(callbackContext);
141
+ break;
134
142
  case "userSubscriptions":
135
143
  userSubscriptions(callbackContext);
136
144
  break;
137
145
  case "handle":
138
- handle(args.getString(0), callbackContext);
146
+ handle(getStringFromJson(args.getString(0)), callbackContext);
139
147
  break;
140
148
  case "allProducts":
141
149
  allProducts(callbackContext);
142
150
  break;
143
151
  case "productWithIdentifier":
144
- productWithIdentifier(args.getString(0), callbackContext);
152
+ productWithIdentifier(getStringFromJson(args.getString(0)), callbackContext);
145
153
  break;
146
154
  case "planWithIdentifier":
147
- planWithIdentifier(args.getString(0), callbackContext);
155
+ planWithIdentifier(getStringFromJson(args.getString(0)), callbackContext);
148
156
  break;
149
157
  case "purchaseWithPlanVendorId":
150
158
  purchaseWithPlanVendorId(
151
- args.getString(0),
152
- args.getString(1),
159
+ getStringFromJson(args.getString(0)),
160
+ getStringFromJson(args.getString(1)),
153
161
  callbackContext
154
162
  );
155
163
  break;
@@ -175,6 +183,14 @@ public class PurchaselyPlugin extends CordovaPlugin {
175
183
  return true;
176
184
  }
177
185
 
186
+ private String getStringFromJson(String value) {
187
+ if(value == null || value.equals("null") || value.isEmpty()) {
188
+ return null;
189
+ }
190
+
191
+ return value;
192
+ }
193
+
178
194
  public static void sendPurchaseResult(PLYProductViewResult result, PLYPlan plan) {
179
195
  int productViewResult = 0;
180
196
  if(result == PLYProductViewResult.PURCHASED) {
@@ -318,6 +334,14 @@ public class PurchaselyPlugin extends CordovaPlugin {
318
334
  Purchasely.setLogLevel(LogLevel.values()[logLevel]);
319
335
  }
320
336
 
337
+ private void setLanguage(String language) {
338
+ try {
339
+ Purchasely.setLanguage(new Locale(language));
340
+ } catch (Exception e) {
341
+ Purchasely.setLanguage(Locale.getDefault());
342
+ }
343
+ }
344
+
321
345
  private void isReadyToPurchase(boolean isReadyToPurchase) {
322
346
  Purchasely.setReadyToPurchase(isReadyToPurchase);
323
347
  }
@@ -163,6 +163,14 @@
163
163
  }];
164
164
  }
165
165
 
166
+ - (void)silentRestoreAllProducts:(CDVInvokedUrlCommand*)command {
167
+ [Purchasely silentRestoreAllProductsWithSuccess:^{
168
+ [self successFor:command];
169
+ } failure:^(NSError * _Nonnull error) {
170
+ [self failureFor:command resultString:error.localizedDescription];
171
+ }];
172
+ }
173
+
166
174
  - (void)purchasedSubscription:(CDVInvokedUrlCommand*)command {
167
175
  self.purchasedCommand = command;
168
176
  [[NSNotificationCenter defaultCenter] addObserver:self
@@ -249,6 +257,12 @@
249
257
  - (void)close:(CDVInvokedUrlCommand*)command {
250
258
  }
251
259
 
260
+ - (void)setLanguage:(CDVInvokedUrlCommand*)command {
261
+ NSString *language = [command argumentAtIndex:0];
262
+ NSLocale *locale = [NSLocale localeWithLocaleIdentifier:language];
263
+ [Purchasely setLanguageFrom:locale];
264
+ }
265
+
252
266
  - (void)setLoginTappedHandler:(CDVInvokedUrlCommand*)command {
253
267
  self.loginTappedCommand = command;
254
268
  [Purchasely setLoginTappedHandler:^(UIViewController * _Nonnull controller, void (^ _Nonnull closedHandler)(BOOL)) {
@@ -285,8 +299,12 @@
285
299
  - (void)processToPayment:(CDVInvokedUrlCommand*)command {
286
300
  BOOL processToPayment = [[command argumentAtIndex:0] boolValue];
287
301
 
288
- [Purchasely showController:self.presentedPresentationViewController type: PLYUIControllerTypeProductPage];
289
- self.authorizePurchaseHandler(processToPayment);
302
+ if (self.presentedPresentationViewController != nil) {
303
+ [Purchasely showController:self.presentedPresentationViewController type: PLYUIControllerTypeProductPage];
304
+ if (self.authorizePurchaseHandler != nil) {
305
+ self.authorizePurchaseHandler(processToPayment);
306
+ }
307
+ }
290
308
  }
291
309
 
292
310
  // Helpers
package/www/Purchasely.js CHANGED
@@ -86,6 +86,10 @@ exports.restoreAllProducts = function (success, error) {
86
86
  exec(success, error, 'Purchasely', 'restoreAllProducts', []);
87
87
  };
88
88
 
89
+ exports.silentRestoreAllProducts = function (success, error) {
90
+ exec(success, error, 'Purchasely', 'silentRestoreAllProducts', []);
91
+ };
92
+
89
93
  exports.purchasedSubscription = function (success, error) {
90
94
  exec(success, error, 'Purchasely', 'purchasedSubscription', []);
91
95
  };
@@ -126,6 +130,10 @@ exports.userSubscriptions = function (success, error) {
126
130
  exec(success, defaultError, 'Purchasely', 'userSubscriptions', []);
127
131
  };
128
132
 
133
+ exports.setLanguage = function (language) {
134
+ exec(() => {}, defaultError, 'Purchasely', 'setLanguage', [language]);
135
+ };
136
+
129
137
  exports.LogLevel = {
130
138
  DEBUG: 0,
131
139
  INFO: 1,
@@ -136,7 +144,8 @@ exports.LogLevel = {
136
144
  exports.Attribute = {
137
145
  AMPLITUDE_SESSION_ID: 0,
138
146
  FIREBASE_APP_INSTANCE_ID: 1,
139
- AIRSHIP_CHANNEL_ID: 2
147
+ AIRSHIP_CHANNEL_ID: 2,
148
+ BATCH_INSTALLATION_ID: 3
140
149
  }
141
150
 
142
151
  exports.PurchaseResult = {
@@ -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>