@purchasely/cordova-plugin-purchasely 1.1.5 → 1.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/VERSIONS.md CHANGED
@@ -10,3 +10,7 @@ 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 |
@@ -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.4",
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,9 +13,9 @@
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": {
@@ -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.5",
3
+ "version": "1.2.0",
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="cordova-plugin-purchasely" version="1.1.5" 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.0" 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;
@@ -84,6 +86,9 @@ public class PurchaselyPlugin extends CordovaPlugin {
84
86
  case "userLogout":
85
87
  userLogout();
86
88
  break;
89
+ case "setLanguage":
90
+ setLanguage(args.getString(0));
91
+ break;
87
92
  case "setLogLevel":
88
93
  setLogLevel(args.getInt(0));
89
94
  break;
@@ -131,6 +136,9 @@ 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;
@@ -318,6 +326,14 @@ public class PurchaselyPlugin extends CordovaPlugin {
318
326
  Purchasely.setLogLevel(LogLevel.values()[logLevel]);
319
327
  }
320
328
 
329
+ private void setLanguage(String language) {
330
+ try {
331
+ Purchasely.setLanguage(new Locale(language));
332
+ } catch (Exception e) {
333
+ Purchasely.setLanguage(Locale.getDefault());
334
+ }
335
+ }
336
+
321
337
  private void isReadyToPurchase(boolean isReadyToPurchase) {
322
338
  Purchasely.setReadyToPurchase(isReadyToPurchase);
323
339
  }
@@ -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>