@purchasely/cordova-plugin-purchasely 2.2.3 → 2.2.4

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.
@@ -9,8 +9,7 @@
9
9
  "version": "1.0.0",
10
10
  "license": "Apache-2.0",
11
11
  "devDependencies": {
12
- "@purchasely/cordova-plugin-purchasely": "^2.2.2",
13
- "cordova-android": "^10.1.0",
12
+ "cordova-android": "^10.1.2",
14
13
  "cordova-ios": "^6.2.0",
15
14
  "cordova-plugin-purchasely": "file:.."
16
15
  }
@@ -67,12 +66,6 @@
67
66
  "node": ">= 8"
68
67
  }
69
68
  },
70
- "node_modules/@purchasely/cordova-plugin-purchasely": {
71
- "version": "2.2.2",
72
- "resolved": "https://registry.npmjs.org/@purchasely/cordova-plugin-purchasely/-/cordova-plugin-purchasely-2.2.2.tgz",
73
- "integrity": "sha512-0d8Bfh2RKLU2D+kMiZ75SqeT3/5C3BaTFRFi6+cTKzrZcycjRW1nhHP1lvjoHXvaDDh9bxVMVKt2uCtTtE8xig==",
74
- "dev": true
75
- },
76
69
  "node_modules/abbrev": {
77
70
  "version": "1.1.1",
78
71
  "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -206,9 +199,9 @@
206
199
  "dev": true
207
200
  },
208
201
  "node_modules/cordova-android": {
209
- "version": "10.1.0",
210
- "resolved": "https://registry.npmjs.org/cordova-android/-/cordova-android-10.1.0.tgz",
211
- "integrity": "sha512-nkVh8VMDWoDmvWaQav/sF3Q7N9ZpRRNBJduDhjCOMwYUF/6q2526i/Jb/wJLdXmetBNh+THkGolcTBi9i+1UzA==",
202
+ "version": "10.1.2",
203
+ "resolved": "https://registry.npmjs.org/cordova-android/-/cordova-android-10.1.2.tgz",
204
+ "integrity": "sha512-F28+NvgKO4ZhKFkqctCOh62mhVoNyUuRQh/F/nqp+Sti4ODv2rUa6UeW18khhdYTjlDeihHQsPqxvB7mI6fVYA==",
212
205
  "dev": true,
213
206
  "dependencies": {
214
207
  "android-versions": "^1.7.0",
@@ -228,9 +221,9 @@
228
221
  }
229
222
  },
230
223
  "node_modules/cordova-android/node_modules/fs-extra": {
231
- "version": "10.0.1",
232
- "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz",
233
- "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==",
224
+ "version": "10.1.0",
225
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
226
+ "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
234
227
  "dev": true,
235
228
  "dependencies": {
236
229
  "graceful-fs": "^4.2.0",
@@ -855,7 +848,7 @@
855
848
  "node_modules/properties-parser": {
856
849
  "version": "0.3.1",
857
850
  "resolved": "https://registry.npmjs.org/properties-parser/-/properties-parser-0.3.1.tgz",
858
- "integrity": "sha1-ExbpU5/7/ZOEXjabIRAiq9R4dxo=",
851
+ "integrity": "sha512-AkSQxQAviJ89x4FIxOyHGfO3uund0gvYo7lfD0E+Gp7gFQKrTNgtoYQklu8EhrfHVZUzTwKGZx2r/KDSfnljcA==",
859
852
  "dev": true,
860
853
  "dependencies": {
861
854
  "string.prototype.codepointat": "^0.2.0"
@@ -1283,12 +1276,6 @@
1283
1276
  "fastq": "^1.6.0"
1284
1277
  }
1285
1278
  },
1286
- "@purchasely/cordova-plugin-purchasely": {
1287
- "version": "2.2.2",
1288
- "resolved": "https://registry.npmjs.org/@purchasely/cordova-plugin-purchasely/-/cordova-plugin-purchasely-2.2.2.tgz",
1289
- "integrity": "sha512-0d8Bfh2RKLU2D+kMiZ75SqeT3/5C3BaTFRFi6+cTKzrZcycjRW1nhHP1lvjoHXvaDDh9bxVMVKt2uCtTtE8xig==",
1290
- "dev": true
1291
- },
1292
1279
  "abbrev": {
1293
1280
  "version": "1.1.1",
1294
1281
  "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -1392,9 +1379,9 @@
1392
1379
  "dev": true
1393
1380
  },
1394
1381
  "cordova-android": {
1395
- "version": "10.1.0",
1396
- "resolved": "https://registry.npmjs.org/cordova-android/-/cordova-android-10.1.0.tgz",
1397
- "integrity": "sha512-nkVh8VMDWoDmvWaQav/sF3Q7N9ZpRRNBJduDhjCOMwYUF/6q2526i/Jb/wJLdXmetBNh+THkGolcTBi9i+1UzA==",
1382
+ "version": "10.1.2",
1383
+ "resolved": "https://registry.npmjs.org/cordova-android/-/cordova-android-10.1.2.tgz",
1384
+ "integrity": "sha512-F28+NvgKO4ZhKFkqctCOh62mhVoNyUuRQh/F/nqp+Sti4ODv2rUa6UeW18khhdYTjlDeihHQsPqxvB7mI6fVYA==",
1398
1385
  "dev": true,
1399
1386
  "requires": {
1400
1387
  "android-versions": "^1.7.0",
@@ -1411,9 +1398,9 @@
1411
1398
  },
1412
1399
  "dependencies": {
1413
1400
  "fs-extra": {
1414
- "version": "10.0.1",
1415
- "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz",
1416
- "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==",
1401
+ "version": "10.1.0",
1402
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
1403
+ "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
1417
1404
  "dev": true,
1418
1405
  "requires": {
1419
1406
  "graceful-fs": "^4.2.0",
@@ -1895,7 +1882,7 @@
1895
1882
  "properties-parser": {
1896
1883
  "version": "0.3.1",
1897
1884
  "resolved": "https://registry.npmjs.org/properties-parser/-/properties-parser-0.3.1.tgz",
1898
- "integrity": "sha1-ExbpU5/7/ZOEXjabIRAiq9R4dxo=",
1885
+ "integrity": "sha512-AkSQxQAviJ89x4FIxOyHGfO3uund0gvYo7lfD0E+Gp7gFQKrTNgtoYQklu8EhrfHVZUzTwKGZx2r/KDSfnljcA==",
1899
1886
  "dev": true,
1900
1887
  "requires": {
1901
1888
  "string.prototype.codepointat": "^0.2.0"
@@ -13,16 +13,12 @@
13
13
  "author": "Apache Cordova Team",
14
14
  "license": "Apache-2.0",
15
15
  "devDependencies": {
16
- "@purchasely/cordova-plugin-purchasely": "^2.2.2",
17
- "cordova-android": "^10.1.0",
16
+ "cordova-android": "^10.1.2",
18
17
  "cordova-ios": "^6.2.0",
19
18
  "cordova-plugin-purchasely": "file:.."
20
19
  },
21
20
  "cordova": {
22
- "plugins": {
23
- "@purchasely/cordova-plugin-purchasely": {},
24
- "cordova-plugin-purchasely": {}
25
- },
21
+ "plugins": {},
26
22
  "platforms": [
27
23
  "android"
28
24
  ]
@@ -30,7 +30,7 @@ function onDeviceReady() {
30
30
  Purchasely.setLanguage('en')
31
31
 
32
32
  Purchasely.startWithAPIKey(
33
- 'afa96c76-1d8e-4e3c-a48f-204a3cd93a15',
33
+ 'fcb39be4-2ba4-4db7-bde3-2a5a1e20745d',
34
34
  ['Google'],
35
35
  null,
36
36
  Purchasely.LogLevel.DEBUG,
@@ -126,7 +126,7 @@ function onPuchaselySdkReady() {
126
126
  result.parameters.url
127
127
  );
128
128
  console.log('prevent Purchasely SDK to navigate to website');
129
- Purchasely.onProcessAction(false);
129
+ Purchasely.onProcessAction(true);
130
130
  } else if (result.action === Purchasely.PaywallAction.close) {
131
131
  console.log('User wants to close paywall');
132
132
  Purchasely.onProcessAction(true);
@@ -144,7 +144,6 @@ function onPuchaselySdkReady() {
144
144
  console.log('User wants to purchase');
145
145
  //If you want to intercept it, close paywall and display your screen
146
146
  Purchasely.closePaywall();
147
- Purchasely.onProcessAction(true);
148
147
  } else if (result.action === Purchasely.PaywallAction.restore) {
149
148
  console.log('User wants to restore his purchases');
150
149
  Purchasely.onProcessAction(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purchasely/cordova-plugin-purchasely",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
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="2.2.2" 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="2.2.4" 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" />
@@ -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:3.2.1" />
54
+ <framework src="io.purchasely:core:3.2.2" />
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" />
@@ -59,7 +59,8 @@ public class PurchaselyPlugin extends CordovaPlugin {
59
59
  static CallbackContext eventsCallback = null;
60
60
  static ProductActivity productActivity = null;
61
61
 
62
- private PLYProcessActionListener processActionListener;
62
+ @Nullable private PLYProcessActionListener processActionListener;
63
+ @Nullable private PLYPresentationAction paywallAction;
63
64
 
64
65
  private static int runningModeTransactionOnly = 0;
65
66
  private static int runningModeObserver = 1;
@@ -586,6 +587,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
586
587
  Purchasely.setPaywallActionsInterceptor(
587
588
  (info, plyPresentationAction, map, plyProcessActionListener) -> {
588
589
  processActionListener = plyProcessActionListener;
590
+ paywallAction = plyPresentationAction;
589
591
 
590
592
  String url = null;
591
593
  if(map.getUrl() != null) {
@@ -620,7 +622,10 @@ public class PurchaselyPlugin extends CordovaPlugin {
620
622
  }
621
623
 
622
624
  private void closePaywall(CallbackContext callbackContext) {
623
- Activity purchaselyActivity = productActivity.activity.get();
625
+ Activity purchaselyActivity = null;
626
+ if(productActivity != null && productActivity.activity != null) {
627
+ purchaselyActivity = productActivity.activity.get();
628
+ }
624
629
  Activity activity = purchaselyActivity != null ? purchaselyActivity : cordova.getActivity();
625
630
  Intent intent = new Intent(activity, cordova.getActivity().getClass());
626
631
  intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@@ -628,24 +633,40 @@ public class PurchaselyPlugin extends CordovaPlugin {
628
633
  }
629
634
 
630
635
  private void onProcessAction(boolean processAction) {
631
- if(processActionListener != null) {
632
- if(productActivity != null) {
633
- boolean softRelaunched = productActivity.relaunch(cordova);
634
- if(softRelaunched) {
636
+ if(processActionListener == null) return;
637
+
638
+ PLYPresentationAction action = PLYPresentationAction.CLOSE;
639
+ if(paywallAction != null) action = paywallAction;
640
+
641
+ switch (action) {
642
+ case PROMO_CODE:
643
+ case RESTORE:
644
+ case PURCHASE:
645
+ case LOGIN:
646
+ case OPEN_PRESENTATION:
647
+ processActionWithPaywallActivity(processAction);
648
+ break;
649
+ default:
650
+ cordova.getActivity().runOnUiThread(() -> processActionListener.processAction(processAction));
651
+ }
652
+ }
653
+
654
+ private void processActionWithPaywallActivity(boolean processAction) {
655
+ if(processActionListener == null) return;
656
+
657
+ boolean softRelaunched = productActivity != null && productActivity.relaunch(cordova);
658
+ if(softRelaunched) {
659
+ cordova.getActivity().runOnUiThread(() -> processActionListener.processAction(processAction));
660
+ } else {
661
+ new Thread(() -> {
662
+ try {
663
+ Thread.sleep(500);
664
+ } catch (InterruptedException e) {
665
+ Log.e("Purchasely", "process action error", e);
666
+ } finally {
635
667
  cordova.getActivity().runOnUiThread(() -> processActionListener.processAction(processAction));
636
- } else {
637
- new Thread(() -> {
638
- try {
639
- Thread.sleep(500);
640
- } catch (InterruptedException e) {
641
- Log.e("Purchasely", "process action error", e);
642
- } finally {
643
- cordova.getActivity().runOnUiThread(() -> processActionListener.processAction(processAction));
644
- }
645
- }).start();
646
668
  }
647
-
648
- }
669
+ }).start();
649
670
  }
650
671
  }
651
672
 
@@ -673,10 +694,15 @@ public class PurchaselyPlugin extends CordovaPlugin {
673
694
  String productId = null;
674
695
  String planId = null;
675
696
  String contentId = null;
676
- WeakReference<PLYProductActivity> activity = null;
697
+ @Nullable WeakReference<PLYProductActivity> activity = null;
677
698
 
678
699
  public boolean relaunch(CordovaInterface cordova) {
679
- PLYProductActivity backgroundActivity = activity.get();
700
+ PLYProductActivity backgroundActivity = null;
701
+
702
+ if(activity != null) {
703
+ backgroundActivity = activity.get();
704
+ }
705
+
680
706
  if(backgroundActivity != null
681
707
  && !backgroundActivity.isFinishing()
682
708
  && !backgroundActivity.isDestroyed()) {
package/INTERNAL DELETED
@@ -1,33 +0,0 @@
1
- # Purchasely-Cordova-Sources
2
-
3
- ## Add plugin :
4
-
5
- `cd example/`
6
-
7
- `cordova plugin add /home/kevin/Documents/Purchasely/Cordova/Purchasely --link`
8
-
9
-
10
- ## Add android platform :
11
-
12
- `cd example/`
13
-
14
- `cordova platform add android`
15
-
16
- `cordova run android`
17
-
18
- ### Add Google-Play dependencies
19
-
20
- In folder `example/platforms/android/app` create a file called `build-extras.gradle` and add thoses lines :
21
- ```groovy
22
- dependencies {
23
- implementation "io.purchasely:google-play:2.5.5"
24
- }
25
- ```
26
-
27
- ### Troubleshot
28
-
29
- `cd example/`
30
-
31
- `cordova platform remove android`
32
-
33
- `cordova plugin remove cordova-plugin-purchasely`
package/VERSIONS.md DELETED
@@ -1,24 +0,0 @@
1
- This file provides the underlying native SDK versions that the Cordova SDK relies on.
2
-
3
- | Version | iOS version | Android version |
4
- |---------|-------------|-----------------|
5
- | 1.0.2 | 2.5.3 | 2.5.4 |
6
- | 1.0.3 | 2.5.5 | 2.5.5 |
7
- | 1.0.4 | 2.5.5 | 2.5.6 |
8
- | 1.0.5 | 2.6.0 | 2.5.6 |
9
- | 1.1.0 | 2.7.2 | 2.7.2 |
10
- | 1.1.1 | 2.7.3 | 2.7.2 |
11
- | 1.1.2 | 2.7.3 | 2.7.2 |
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
- | 2.0.0 | 3.0.0 | 3.0.1 |
18
- | 2.0.1 | 3.0.0 | 3.0.1 |
19
- | 2.1.0 | 3.1.0 | 3.1.0 |
20
- | 2.1.1 | 3.1.0 | 3.1.0 |
21
- | 2.2.0 | 3.2.0 | 3.2.0 |
22
- | 2.2.1 | 3.2.1 | 3.2.1 |
23
- | 2.2.2 | 3.2.2 | 3.2.2 |
24
- | 2.2.3 | 3.2.3 | 3.2.2 |