@purchasely/cordova-plugin-purchasely 1.2.0 → 2.0.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
@@ -14,3 +14,4 @@ This file provides the underlying native SDK versions that the Cordova SDK relie
14
14
  | 1.1.7 | 2.7.3 | 2.7.4 |
15
15
  | 1.1.8 | 2.7.3 | 2.7.6 |
16
16
  | 1.2.0 | 2.8.0 | 2.8.0 |
17
+ | 2.0.0 | 3.0.0 | 3.0.1 |
@@ -9,7 +9,8 @@
9
9
  "version": "1.0.0",
10
10
  "license": "Apache-2.0",
11
11
  "devDependencies": {
12
- "cordova-android": "^10.1.1",
12
+ "@purchasely/cordova-plugin-purchasely": "file:..",
13
+ "cordova-android": "^10.1.0",
13
14
  "cordova-ios": "^6.2.0",
14
15
  "cordova-plugin-purchasely": "file:..",
15
16
  "cordova-plugin-whitelist": "^1.3.5"
@@ -17,7 +18,7 @@
17
18
  },
18
19
  "..": {
19
20
  "name": "cordova-plugin-purchasely",
20
- "version": "1.2.0",
21
+ "version": "2.0.0",
21
22
  "dev": true,
22
23
  "license": "ISC"
23
24
  },
@@ -67,6 +68,10 @@
67
68
  "node": ">= 8"
68
69
  }
69
70
  },
71
+ "node_modules/@purchasely/cordova-plugin-purchasely": {
72
+ "resolved": "..",
73
+ "link": true
74
+ },
70
75
  "node_modules/abbrev": {
71
76
  "version": "1.1.1",
72
77
  "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -151,12 +156,12 @@
151
156
  }
152
157
  },
153
158
  "node_modules/bplist-creator": {
154
- "version": "0.0.8",
155
- "resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.8.tgz",
156
- "integrity": "sha512-Za9JKzD6fjLC16oX2wsXfc+qBEhJBJB1YPInoAQpMLhDuj5aVOv1baGeIQSq1Fr3OCqzvsoQcSBSwGId/Ja2PA==",
159
+ "version": "0.1.0",
160
+ "resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.1.0.tgz",
161
+ "integrity": "sha512-sXaHZicyEEmY86WyueLTQesbeoH/mquvarJaQNbjuOQO+7gbFcDEWqKmcWA4cOTLzFlfgvkiVxolk1k5bBIpmg==",
157
162
  "dev": true,
158
163
  "dependencies": {
159
- "stream-buffers": "~2.2.0"
164
+ "stream-buffers": "2.2.x"
160
165
  }
161
166
  },
162
167
  "node_modules/bplist-parser": {
@@ -200,9 +205,9 @@
200
205
  "dev": true
201
206
  },
202
207
  "node_modules/cordova-android": {
203
- "version": "10.1.1",
204
- "resolved": "https://registry.npmjs.org/cordova-android/-/cordova-android-10.1.1.tgz",
205
- "integrity": "sha512-eoJp5AcDMHniqmxj0CbUF/rVQfbbp108TWKU6oyJW9rl/ZTJqZxm5ybznl+1/1MBksklxhMeipMn0Iwd0kEzEQ==",
208
+ "version": "10.1.0",
209
+ "resolved": "https://registry.npmjs.org/cordova-android/-/cordova-android-10.1.0.tgz",
210
+ "integrity": "sha512-nkVh8VMDWoDmvWaQav/sF3Q7N9ZpRRNBJduDhjCOMwYUF/6q2526i/Jb/wJLdXmetBNh+THkGolcTBi9i+1UzA==",
206
211
  "dev": true,
207
212
  "dependencies": {
208
213
  "android-versions": "^1.7.0",
@@ -805,14 +810,13 @@
805
810
  }
806
811
  },
807
812
  "node_modules/plist": {
808
- "version": "3.0.2",
809
- "resolved": "https://registry.npmjs.org/plist/-/plist-3.0.2.tgz",
810
- "integrity": "sha512-MSrkwZBdQ6YapHy87/8hDU8MnIcyxBKjeF+McXnr5A9MtffPewTs7G3hlpodT5TacyfIyFTaJEhh3GGcmasTgQ==",
813
+ "version": "3.0.4",
814
+ "resolved": "https://registry.npmjs.org/plist/-/plist-3.0.4.tgz",
815
+ "integrity": "sha512-ksrr8y9+nXOxQB2osVNqrgvX/XQPOXaU4BQMKjYq8PvaY1U18mo+fKgBSwzK+luSyinOuPae956lSVcBwxlAMg==",
811
816
  "dev": true,
812
817
  "dependencies": {
813
818
  "base64-js": "^1.5.1",
814
- "xmlbuilder": "^9.0.7",
815
- "xmldom": "^0.5.0"
819
+ "xmlbuilder": "^9.0.7"
816
820
  },
817
821
  "engines": {
818
822
  "node": ">=6"
@@ -961,9 +965,9 @@
961
965
  }
962
966
  },
963
967
  "node_modules/signal-exit": {
964
- "version": "3.0.5",
965
- "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.5.tgz",
966
- "integrity": "sha512-KWcOiKeQj6ZyXx7zq4YxSMgHRlod4czeBQZrPb8OKcohcqAXShm7E20kEMle9WBt26hFcAf0qLOcp5zmY7kOqQ==",
968
+ "version": "3.0.6",
969
+ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz",
970
+ "integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==",
967
971
  "dev": true
968
972
  },
969
973
  "node_modules/simctl": {
@@ -977,14 +981,26 @@
977
981
  }
978
982
  },
979
983
  "node_modules/simple-plist": {
980
- "version": "1.1.1",
981
- "resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.1.1.tgz",
982
- "integrity": "sha512-pKMCVKvZbZTsqYR6RKgLfBHkh2cV89GXcA/0CVPje3sOiNOnXA8+rp/ciAMZ7JRaUdLzlEM6JFfUn+fS6Nt3hg==",
984
+ "version": "1.3.0",
985
+ "resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.3.0.tgz",
986
+ "integrity": "sha512-uYWpeGFtZtVt2NhG4AHgpwx323zxD85x42heMJBan1qAiqqozIlaGrwrEt6kRjXWRWIXsuV1VLCvVmZan2B5dg==",
983
987
  "dev": true,
984
988
  "dependencies": {
985
- "bplist-creator": "0.0.8",
986
- "bplist-parser": "0.2.0",
987
- "plist": "^3.0.1"
989
+ "bplist-creator": "0.1.0",
990
+ "bplist-parser": "0.3.0",
991
+ "plist": "^3.0.4"
992
+ }
993
+ },
994
+ "node_modules/simple-plist/node_modules/bplist-parser": {
995
+ "version": "0.3.0",
996
+ "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.0.tgz",
997
+ "integrity": "sha512-zgmaRvT6AN1JpPPV+S0a1/FAtoxSreYDccZGIqEMSvZl9DMe70mJ7MFzpxa1X+gHVdkToE2haRUHHMiW1OdejA==",
998
+ "dev": true,
999
+ "dependencies": {
1000
+ "big-integer": "1.6.x"
1001
+ },
1002
+ "engines": {
1003
+ "node": ">= 5.10.0"
988
1004
  }
989
1005
  },
990
1006
  "node_modules/stream-buffers": {
@@ -1146,15 +1162,6 @@
1146
1162
  "node": ">=4.0"
1147
1163
  }
1148
1164
  },
1149
- "node_modules/xmldom": {
1150
- "version": "0.5.0",
1151
- "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.5.0.tgz",
1152
- "integrity": "sha512-Foaj5FXVzgn7xFzsKeNIde9g6aFBxTPi37iwsno8QvApmtg7KYrr+OPyRHcJF7dud2a5nGRBXK3n0dL62Gf7PA==",
1153
- "dev": true,
1154
- "engines": {
1155
- "node": ">=10.0.0"
1156
- }
1157
- },
1158
1165
  "node_modules/yallist": {
1159
1166
  "version": "4.0.0",
1160
1167
  "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
@@ -1200,6 +1207,9 @@
1200
1207
  "fastq": "^1.6.0"
1201
1208
  }
1202
1209
  },
1210
+ "@purchasely/cordova-plugin-purchasely": {
1211
+ "version": "file:.."
1212
+ },
1203
1213
  "abbrev": {
1204
1214
  "version": "1.1.1",
1205
1215
  "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -1260,12 +1270,12 @@
1260
1270
  "dev": true
1261
1271
  },
1262
1272
  "bplist-creator": {
1263
- "version": "0.0.8",
1264
- "resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.8.tgz",
1265
- "integrity": "sha512-Za9JKzD6fjLC16oX2wsXfc+qBEhJBJB1YPInoAQpMLhDuj5aVOv1baGeIQSq1Fr3OCqzvsoQcSBSwGId/Ja2PA==",
1273
+ "version": "0.1.0",
1274
+ "resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.1.0.tgz",
1275
+ "integrity": "sha512-sXaHZicyEEmY86WyueLTQesbeoH/mquvarJaQNbjuOQO+7gbFcDEWqKmcWA4cOTLzFlfgvkiVxolk1k5bBIpmg==",
1266
1276
  "dev": true,
1267
1277
  "requires": {
1268
- "stream-buffers": "~2.2.0"
1278
+ "stream-buffers": "2.2.x"
1269
1279
  }
1270
1280
  },
1271
1281
  "bplist-parser": {
@@ -1303,9 +1313,9 @@
1303
1313
  "dev": true
1304
1314
  },
1305
1315
  "cordova-android": {
1306
- "version": "10.1.1",
1307
- "resolved": "https://registry.npmjs.org/cordova-android/-/cordova-android-10.1.1.tgz",
1308
- "integrity": "sha512-eoJp5AcDMHniqmxj0CbUF/rVQfbbp108TWKU6oyJW9rl/ZTJqZxm5ybznl+1/1MBksklxhMeipMn0Iwd0kEzEQ==",
1316
+ "version": "10.1.0",
1317
+ "resolved": "https://registry.npmjs.org/cordova-android/-/cordova-android-10.1.0.tgz",
1318
+ "integrity": "sha512-nkVh8VMDWoDmvWaQav/sF3Q7N9ZpRRNBJduDhjCOMwYUF/6q2526i/Jb/wJLdXmetBNh+THkGolcTBi9i+1UzA==",
1309
1319
  "dev": true,
1310
1320
  "requires": {
1311
1321
  "android-versions": "^1.7.0",
@@ -1764,14 +1774,13 @@
1764
1774
  "dev": true
1765
1775
  },
1766
1776
  "plist": {
1767
- "version": "3.0.2",
1768
- "resolved": "https://registry.npmjs.org/plist/-/plist-3.0.2.tgz",
1769
- "integrity": "sha512-MSrkwZBdQ6YapHy87/8hDU8MnIcyxBKjeF+McXnr5A9MtffPewTs7G3hlpodT5TacyfIyFTaJEhh3GGcmasTgQ==",
1777
+ "version": "3.0.4",
1778
+ "resolved": "https://registry.npmjs.org/plist/-/plist-3.0.4.tgz",
1779
+ "integrity": "sha512-ksrr8y9+nXOxQB2osVNqrgvX/XQPOXaU4BQMKjYq8PvaY1U18mo+fKgBSwzK+luSyinOuPae956lSVcBwxlAMg==",
1770
1780
  "dev": true,
1771
1781
  "requires": {
1772
1782
  "base64-js": "^1.5.1",
1773
- "xmlbuilder": "^9.0.7",
1774
- "xmldom": "^0.5.0"
1783
+ "xmlbuilder": "^9.0.7"
1775
1784
  }
1776
1785
  },
1777
1786
  "properties-parser": {
@@ -1857,9 +1866,9 @@
1857
1866
  "dev": true
1858
1867
  },
1859
1868
  "signal-exit": {
1860
- "version": "3.0.5",
1861
- "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.5.tgz",
1862
- "integrity": "sha512-KWcOiKeQj6ZyXx7zq4YxSMgHRlod4czeBQZrPb8OKcohcqAXShm7E20kEMle9WBt26hFcAf0qLOcp5zmY7kOqQ==",
1869
+ "version": "3.0.6",
1870
+ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz",
1871
+ "integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==",
1863
1872
  "dev": true
1864
1873
  },
1865
1874
  "simctl": {
@@ -1873,14 +1882,25 @@
1873
1882
  }
1874
1883
  },
1875
1884
  "simple-plist": {
1876
- "version": "1.1.1",
1877
- "resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.1.1.tgz",
1878
- "integrity": "sha512-pKMCVKvZbZTsqYR6RKgLfBHkh2cV89GXcA/0CVPje3sOiNOnXA8+rp/ciAMZ7JRaUdLzlEM6JFfUn+fS6Nt3hg==",
1885
+ "version": "1.3.0",
1886
+ "resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.3.0.tgz",
1887
+ "integrity": "sha512-uYWpeGFtZtVt2NhG4AHgpwx323zxD85x42heMJBan1qAiqqozIlaGrwrEt6kRjXWRWIXsuV1VLCvVmZan2B5dg==",
1879
1888
  "dev": true,
1880
1889
  "requires": {
1881
- "bplist-creator": "0.0.8",
1882
- "bplist-parser": "0.2.0",
1883
- "plist": "^3.0.1"
1890
+ "bplist-creator": "0.1.0",
1891
+ "bplist-parser": "0.3.0",
1892
+ "plist": "^3.0.4"
1893
+ },
1894
+ "dependencies": {
1895
+ "bplist-parser": {
1896
+ "version": "0.3.0",
1897
+ "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.0.tgz",
1898
+ "integrity": "sha512-zgmaRvT6AN1JpPPV+S0a1/FAtoxSreYDccZGIqEMSvZl9DMe70mJ7MFzpxa1X+gHVdkToE2haRUHHMiW1OdejA==",
1899
+ "dev": true,
1900
+ "requires": {
1901
+ "big-integer": "1.6.x"
1902
+ }
1903
+ }
1884
1904
  }
1885
1905
  },
1886
1906
  "stream-buffers": {
@@ -2000,12 +2020,6 @@
2000
2020
  "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=",
2001
2021
  "dev": true
2002
2022
  },
2003
- "xmldom": {
2004
- "version": "0.5.0",
2005
- "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.5.0.tgz",
2006
- "integrity": "sha512-Foaj5FXVzgn7xFzsKeNIde9g6aFBxTPi37iwsno8QvApmtg7KYrr+OPyRHcJF7dud2a5nGRBXK3n0dL62Gf7PA==",
2007
- "dev": true
2008
- },
2009
2023
  "yallist": {
2010
2024
  "version": "4.0.0",
2011
2025
  "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
@@ -13,7 +13,8 @@
13
13
  "author": "Apache Cordova Team",
14
14
  "license": "Apache-2.0",
15
15
  "devDependencies": {
16
- "cordova-android": "^10.1.1",
16
+ "@purchasely/cordova-plugin-purchasely": "file:..",
17
+ "cordova-android": "^10.1.0",
17
18
  "cordova-ios": "^6.2.0",
18
19
  "cordova-plugin-purchasely": "file:..",
19
20
  "cordova-plugin-whitelist": "^1.3.5"
@@ -24,8 +25,8 @@
24
25
  "cordova-plugin-purchasely": {}
25
26
  },
26
27
  "platforms": [
27
- "ios",
28
- "android"
28
+ "android",
29
+ "ios"
29
30
  ]
30
31
  }
31
32
  }
@@ -36,7 +36,7 @@ function onDeviceReady() {
36
36
  ['Google'],
37
37
  null,
38
38
  Purchasely.LogLevel.DEBUG,
39
- false,
39
+ Purchasely.RunningMode.full,
40
40
  (isConfigured) => {
41
41
  if(isConfigured) onPuchaselySdkReady();
42
42
  },
@@ -88,6 +88,22 @@ function onPuchaselySdkReady() {
88
88
 
89
89
  Purchasely.isReadyToPurchase(true);
90
90
 
91
+ Purchasely.planWithIdentifier('PURCHASELY_PLUS_MONTHLY', (plan) => {
92
+ console.log(' ==> Plan');
93
+ console.log(plan.vendorId);
94
+ console.log(plan.productId);
95
+ console.log(plan.name);
96
+ console.log(plan.price);
97
+ console.log(plan.amount);
98
+ console.log(plan.period);
99
+ console.log(plan.hasIntroductoryPrice);
100
+ console.log(plan.introPrice);
101
+ console.log(plan.introAmount);
102
+ console.log(plan.introDuration);
103
+ }, (error) => {
104
+ console.log(error);
105
+ });
106
+
91
107
  Purchasely.setDefaultPresentationResultHandler(callback => {
92
108
  console.log(callback);
93
109
  if(callback.result == Purchasely.PurchaseResult.CANCELLED) {
@@ -96,20 +112,48 @@ function onPuchaselySdkReady() {
96
112
  console.log("User purchased " + callback.plan.vendorId);
97
113
  }
98
114
  },
99
- (error) => {
115
+ (error) => {
100
116
  console.log("Error with purchase : " + error);
101
117
  });
102
118
 
103
- Purchasely.setLoginTappedHandler(onLoginTapped => {
104
- // Present your own screen for user to log in
105
-
106
- // Call this method to update Purchasely Paywall
107
- Purchasely.userLogin('my_user_id');
108
- Purchasely.onUserLoggedIn(true);
109
- });
110
-
111
- Purchasely.setConfirmPurchaseHandler(onPurchaseTapped => {
112
- // Present your own screen before purchase
119
+ Purchasely.setPaywallActionInterceptor((result) => {
120
+ console.log(result);
121
+ console.log('Received action from paywall ' + result.info.presentationId);
122
+
123
+ if (result.action === Purchasely.PaywallAction.navigate) {
124
+ console.log(
125
+ 'User wants to navigate to website ' +
126
+ result.parameters.title +
127
+ ' ' +
128
+ result.parameters.url
129
+ );
130
+ console.log('prevent Purchasely SDK to navigate to website');
131
+ Purchasely.onProcessAction(false);
132
+ } else if (result.action === Purchasely.PaywallAction.close) {
133
+ console.log('User wants to close paywall');
134
+ Purchasely.onProcessAction(true);
135
+ } else if (result.action === Purchasely.PaywallAction.login) {
136
+ console.log('User wants to login');
137
+ //Present your own screen for user to log in
138
+ Purchasely.closePaywall();
139
+ Purchasely.userLogin('MY_USER_ID');
140
+ //Call this method to update Purchasely Paywall
141
+ Purchasely.onProcessAction(true);
142
+ } else if (result.action === Purchasely.PaywallAction.open_presentation) {
143
+ console.log('User wants to open a new paywall');
144
+ Purchasely.onProcessAction(true);
145
+ } else if (result.action === Purchasely.PaywallAction.purchase) {
146
+ console.log('User wants to purchase');
147
+ //If you want to intercept it, close paywall and display your screen
148
+ Purchasely.closePaywall();
149
+ Purchasely.onProcessAction(true);
150
+ } else if (result.action === Purchasely.PaywallAction.restore) {
151
+ console.log('User wants to restore his purchases');
152
+ Purchasely.onProcessAction(true);
153
+ } else {
154
+ console.log('Action unknown ' + result.action);
155
+ Purchasely.onProcessAction(true);
156
+ }
113
157
  });
114
158
  }
115
159
 
@@ -140,7 +184,7 @@ function purchaseWithPlanVendorId() {
140
184
 
141
185
  function processToPayment() {
142
186
  // Call this method to process to payment
143
- Purchasely.processToPayment(true);
187
+ Purchasely.onProcessAction(true);
144
188
  }
145
189
 
146
190
  function restore() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purchasely/cordova-plugin-purchasely",
3
- "version": "1.2.0",
3
+ "version": "2.0.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="@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">
2
+ <plugin id="@purchasely/cordova-plugin-purchasely" version="2.0.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.8.0"/>
31
+ <pod name="Purchasely" spec="3.0.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.8.0" />
54
+ <framework src="io.purchasely:core:3.0.1" />
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" />
@@ -4,12 +4,17 @@
4
4
  <option name="autoReloadType" value="NONE" />
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
- <list default="true" id="ad0a27bd-64f4-4852-98a1-a7dc8e28a72f" name="Default Changelist" comment="" />
7
+ <list default="true" id="ad0a27bd-64f4-4852-98a1-a7dc8e28a72f" name="Default Changelist" comment="">
8
+ <change beforePath="$PROJECT_DIR$/../../plugin.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../plugin.xml" afterDir="false" />
9
+ </list>
8
10
  <option name="SHOW_DIALOG" value="false" />
9
11
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
12
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
11
13
  <option name="LAST_RESOLUTION" value="IGNORE" />
12
14
  </component>
15
+ <component name="Git.Settings">
16
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../.." />
17
+ </component>
13
18
  <component name="ProjectId" id="1uz33TZxRidCdjXlE00OtDvw6mD" />
14
19
  <component name="ProjectViewState">
15
20
  <option name="hideEmptyMiddlePackages" value="true" />
@@ -18,7 +23,9 @@
18
23
  <component name="PropertiesComponent">
19
24
  <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
20
25
  <property name="android.sdk.path" value="$USER_HOME$/Android/Sdk" />
26
+ <property name="dart.analysis.tool.window.visible" value="false" />
21
27
  <property name="last_opened_file_path" value="$PROJECT_DIR$" />
28
+ <property name="show.migrate.to.gradle.popup" value="false" />
22
29
  </component>
23
30
  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
24
31
  <component name="TaskManager">
@@ -31,4 +38,15 @@
31
38
  </task>
32
39
  <servers />
33
40
  </component>
41
+ <component name="Vcs.Log.Tabs.Properties">
42
+ <option name="TAB_STATES">
43
+ <map>
44
+ <entry key="MAIN">
45
+ <value>
46
+ <State />
47
+ </value>
48
+ </entry>
49
+ </map>
50
+ </option>
51
+ </component>
34
52
  </project>
@@ -32,11 +32,16 @@ public class PLYProductActivity extends AppCompatActivity {
32
32
 
33
33
  Fragment fragment;
34
34
  if(planId != null && !planId.isEmpty()) {
35
- fragment = Purchasely.planFragment(planId, presentationId, contentId, listener);
35
+ fragment = Purchasely.planFragment(planId, presentationId, contentId, null, listener);
36
36
  } else if(productId != null && !productId.isEmpty()) {
37
- fragment = Purchasely.productFragment(productId, presentationId, contentId, listener);
37
+ fragment = Purchasely.productFragment(productId, presentationId, contentId, null, listener);
38
38
  } else {
39
- fragment = Purchasely.presentationFragment(presentationId, contentId, listener);
39
+ fragment = Purchasely.presentationFragment(presentationId, contentId, null, listener);
40
+ }
41
+
42
+ if(fragment == null) {
43
+ supportFinishAfterTransition();
44
+ return;
40
45
  }
41
46
 
42
47
  getSupportFragmentManager().beginTransaction()
@@ -5,6 +5,9 @@ import android.content.Intent;
5
5
  import android.net.Uri;
6
6
  import android.util.Log;
7
7
 
8
+ import androidx.annotation.NonNull;
9
+ import androidx.fragment.app.FragmentActivity;
10
+
8
11
  import org.apache.cordova.CallbackContext;
9
12
  import org.apache.cordova.CordovaInterface;
10
13
  import org.apache.cordova.CordovaPlugin;
@@ -19,18 +22,22 @@ import org.w3c.dom.Attr;
19
22
  import java.lang.ref.WeakReference;
20
23
  import java.util.ArrayList;
21
24
  import java.util.HashMap;
25
+ import java.util.Iterator;
22
26
  import java.util.List;
23
27
  import java.util.Locale;
24
28
  import java.util.Map;
29
+ import java.util.function.BiConsumer;
25
30
 
26
31
  import io.purchasely.billing.Store;
27
32
  import io.purchasely.ext.Attribute;
28
- import io.purchasely.ext.ContinuePurchaseListener;
29
33
  import io.purchasely.ext.DistributionType;
30
34
  import io.purchasely.ext.LogLevel;
31
- import io.purchasely.ext.LoginClosedListener;
32
35
  import io.purchasely.ext.PLYAppTechnology;
36
+ import io.purchasely.ext.PLYPaywallActionListener;
37
+ import io.purchasely.ext.PLYPresentationAction;
38
+ import io.purchasely.ext.PLYProcessActionListener;
33
39
  import io.purchasely.ext.PLYProductViewResult;
40
+ import io.purchasely.ext.PLYRunningMode;
34
41
  import io.purchasely.ext.PlanListener;
35
42
  import io.purchasely.ext.ProductListener;
36
43
  import io.purchasely.ext.ProductsListener;
@@ -52,8 +59,13 @@ public class PurchaselyPlugin extends CordovaPlugin {
52
59
  static CallbackContext eventsCallback = null;
53
60
  static ProductActivity productActivity = null;
54
61
 
55
- private LoginClosedListener loginClosedListener = null;
56
- private ContinuePurchaseListener continuePurchaseListener = null;
62
+ private PLYProcessActionListener processActionListener;
63
+
64
+ private static int runningModeTransactionOnly = 0;
65
+ private static int runningModeObserver = 1;
66
+ private static int runningModePaywallOnly = 2;
67
+ private static int runningModePaywallObserver = 3;
68
+ private static int runningModeFull = 4;
57
69
 
58
70
  @Override
59
71
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
@@ -65,7 +77,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
65
77
  args.getJSONArray(1),
66
78
  args.getString(2),
67
79
  args.getInt(3),
68
- args.getBoolean(4),
80
+ args.getInt(4),
69
81
  callbackContext);
70
82
  break;
71
83
  case "close":
@@ -161,17 +173,14 @@ public class PurchaselyPlugin extends CordovaPlugin {
161
173
  callbackContext
162
174
  );
163
175
  break;
164
- case "setLoginTappedHandler":
165
- setLoginTappedHandler(callbackContext);
176
+ case "setPaywallActionInterceptor":
177
+ setPaywallActionInterceptor(callbackContext);
166
178
  break;
167
- case "onUserLoggedIn":
168
- onUserLoggedIn(args.getBoolean(0));
179
+ case "onProcessAction":
180
+ onProcessAction(args.getBoolean(0));
169
181
  break;
170
- case "setConfirmPurchaseHandler":
171
- setConfirmPurchaseHandler(callbackContext);
172
- break;
173
- case "processToPayment":
174
- processToPayment(args.getBoolean(0));
182
+ case "closePaywall":
183
+ closePaywall(callbackContext);
175
184
  break;
176
185
  default:
177
186
  return false;
@@ -211,7 +220,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
211
220
  JSONArray stores,
212
221
  String userId,
213
222
  int logLevel,
214
- boolean observerMode,
223
+ int runningMode,
215
224
  CallbackContext callbackContext) {
216
225
  ArrayList<String> list = new ArrayList<>();
217
226
  for (int i=0; i< stores.length(); i++) {
@@ -223,11 +232,17 @@ public class PurchaselyPlugin extends CordovaPlugin {
223
232
  }
224
233
  ArrayList<Store> storesInstances = getStoresInstances(list);
225
234
 
235
+ PLYRunningMode plyRunningMode = PLYRunningMode.Full.INSTANCE;
236
+ if(runningMode == runningModeTransactionOnly) plyRunningMode = PLYRunningMode.TransactionOnly.INSTANCE;
237
+ else if(runningMode == runningModeObserver) plyRunningMode = PLYRunningMode.Observer.INSTANCE;
238
+ else if(runningMode == runningModePaywallOnly) plyRunningMode = PLYRunningMode.PaywallOnly.INSTANCE;
239
+ else if(runningMode == runningModePaywallObserver) plyRunningMode = PLYRunningMode.PaywallObserver.INSTANCE;
240
+
226
241
  new Purchasely.Builder(cordova.getContext())
227
242
  .apiKey(apiKey)
228
243
  .stores(storesInstances)
229
244
  .userId(userId)
230
- .observerMode(observerMode)
245
+ .runningMode(plyRunningMode)
231
246
  .logLevel(LogLevel.values()[logLevel])
232
247
  .build();
233
248
 
@@ -275,8 +290,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
275
290
  private void close() {
276
291
  defaultCallback = null;
277
292
  presentationCallback = null;
278
- loginClosedListener = null;
279
- continuePurchaseListener = null;
293
+ processActionListener = null;
280
294
  productActivity = null;
281
295
  Purchasely.close();
282
296
  }
@@ -469,7 +483,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
469
483
  }
470
484
 
471
485
  private void productWithIdentifier(String vendorId, CallbackContext callbackContext) {
472
- Purchasely.getProduct(vendorId, new ProductListener() {
486
+ Purchasely.product(vendorId, new ProductListener() {
473
487
  @Override
474
488
  public void onSuccess(@Nullable PLYProduct plyProduct) {
475
489
  if(plyProduct != null) {
@@ -487,7 +501,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
487
501
  }
488
502
 
489
503
  private void planWithIdentifier(String vendorId, CallbackContext callbackContext) {
490
- Purchasely.getPlan(vendorId, new PlanListener() {
504
+ Purchasely.plan(vendorId, new PlanListener() {
491
505
  @Override
492
506
  public void onSuccess(@Nullable PLYPlan plyPlan) {
493
507
  if(plyPlan != null) {
@@ -505,7 +519,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
505
519
  }
506
520
 
507
521
  private void purchaseWithPlanVendorId(String planVendorId, String contentId, CallbackContext callbackContext) {
508
- Purchasely.getPlan(planVendorId, new PlanListener() {
522
+ Purchasely.plan(planVendorId, new PlanListener() {
509
523
  @Override
510
524
  public void onSuccess(@Nullable PLYPlan plyPlan) {
511
525
  if(plyPlan != null) {
@@ -528,53 +542,57 @@ public class PurchaselyPlugin extends CordovaPlugin {
528
542
  });
529
543
  }
530
544
 
531
- private void setLoginTappedHandler(CallbackContext callbackContext) {
532
- Purchasely.setLoginTappedHandler((fragmentActivity, loginClosedListener) -> {
533
- this.loginClosedListener = loginClosedListener;
534
- Intent intent = new Intent(fragmentActivity, cordova.getActivity().getClass());
535
- intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
536
- cordova.getActivity().startActivity(intent);
545
+ private void setPaywallActionInterceptor(CallbackContext callbackContext) {
546
+ Purchasely.setPaywallActionsInterceptor(
547
+ (info, plyPresentationAction, map, plyProcessActionListener) -> {
548
+ processActionListener = plyProcessActionListener;
537
549
 
538
- PluginResult result = new PluginResult(PluginResult.Status.OK);
539
- result.setKeepCallback(true);
540
- callbackContext.sendPluginResult(result);
541
- });
542
- }
550
+ HashMap<String, Object> parametersForCordova = new HashMap<>();
551
+ parametersForCordova.put("title", map.getTitle());
552
+ parametersForCordova.put("url", map.getUrl());
553
+ parametersForCordova.put("plan", transformPlanToMap(map.getPlan()));
554
+ parametersForCordova.put("presentation", map.getPresentation());
543
555
 
544
- private void onUserLoggedIn(boolean userLoggedIn) {
545
- if(loginClosedListener != null) {
546
- if(productActivity != null) productActivity.relaunch(cordova);
547
- cordova.getActivity().runOnUiThread(() -> loginClosedListener.userLoggedIn(userLoggedIn));
548
- }
549
- }
556
+ HashMap<String, Object> infoMap = new HashMap<>();
557
+ if(info.getContentId() != null) infoMap.put("contentId", info.getContentId());
558
+ if(info.getPresentationId() != null) infoMap.put("presentationId", info.getPresentationId());
550
559
 
551
- private void setConfirmPurchaseHandler(CallbackContext callbackContext) {
552
- Purchasely.setConfirmPurchaseHandler((fragmentActivity, continuePurchaseListener) -> {
553
- this.continuePurchaseListener = continuePurchaseListener;
554
- Intent intent = new Intent(fragmentActivity, cordova.getActivity().getClass());
555
- intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
556
- cordova.getActivity().startActivity(intent);
560
+ HashMap<String, Object> resultForCordova = new HashMap<>();
561
+ resultForCordova.put("info", infoMap);
562
+ resultForCordova.put("action", plyPresentationAction.getValue());
563
+ resultForCordova.put("parameters", parametersForCordova);
557
564
 
558
- PluginResult result = new PluginResult(PluginResult.Status.OK);
565
+ PluginResult result = new PluginResult(
566
+ PluginResult.Status.OK,
567
+ new JSONObject(resultForCordova)
568
+ );
559
569
  result.setKeepCallback(true);
560
570
  callbackContext.sendPluginResult(result);
561
571
  });
562
572
  }
563
573
 
564
- private void processToPayment(boolean continueToPayment) {
565
- if(continuePurchaseListener != null) {
574
+ private void closePaywall(CallbackContext callbackContext) {
575
+ Activity purchaselyActivity = productActivity.activity.get();
576
+ Activity activity = purchaselyActivity != null ? purchaselyActivity : cordova.getActivity();
577
+ Intent intent = new Intent(activity, cordova.getActivity().getClass());
578
+ intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
579
+ cordova.getActivity().startActivity(intent);
580
+ }
581
+
582
+ private void onProcessAction(boolean processAction) {
583
+ if(processActionListener != null) {
566
584
  if(productActivity != null) {
567
585
  boolean softRelaunched = productActivity.relaunch(cordova);
568
586
  if(softRelaunched) {
569
- cordova.getActivity().runOnUiThread(() -> continuePurchaseListener.processToPayment(continueToPayment));
587
+ cordova.getActivity().runOnUiThread(() -> processActionListener.processAction(processAction));
570
588
  } else {
571
589
  new Thread(() -> {
572
590
  try {
573
591
  Thread.sleep(500);
574
592
  } catch (InterruptedException e) {
575
- Log.e("Purchasely", "process to payment error", e);
593
+ Log.e("Purchasely", "process action error", e);
576
594
  } finally {
577
- cordova.getActivity().runOnUiThread(() -> continuePurchaseListener.processToPayment(continueToPayment));
595
+ cordova.getActivity().runOnUiThread(() -> processActionListener.processAction(processAction));
578
596
  }
579
597
  }).start();
580
598
  }
@@ -11,16 +11,13 @@
11
11
  @interface CDVPurchasely<PLYEventDelegate> : CDVPlugin {
12
12
  }
13
13
 
14
- @property (nonatomic, retain) UIViewController* presentedPresentationViewController;
14
+ @property (nonatomic, assign) UIViewController* presentedPresentationViewController;
15
15
 
16
16
  @property CDVInvokedUrlCommand* purchasedCommand;
17
17
  @property CDVInvokedUrlCommand* eventCommand;
18
18
 
19
- @property CDVInvokedUrlCommand* loginTappedCommand;
20
- @property void (^loginClosedHandler)(BOOL loggedIn);
21
-
22
- @property CDVInvokedUrlCommand* authorizePurchaseCommand;
23
- @property void (^authorizePurchaseHandler)(BOOL authorizePurchase);
19
+ @property CDVInvokedUrlCommand* paywallActionInterceptorCommand;
20
+ @property void (^onProcessActionHandler)(BOOL proceed);
24
21
 
25
22
  - (void)startWithAPIKey:(CDVInvokedUrlCommand*)command;
26
23
  - (void)setLogLevel:(CDVInvokedUrlCommand*)command;
@@ -36,6 +33,7 @@
36
33
  - (void)presentSubscriptions:(CDVInvokedUrlCommand*)command;
37
34
  - (void)purchaseWithPlanVendorId:(CDVInvokedUrlCommand*)command;
38
35
  - (void)restoreAllProducts:(CDVInvokedUrlCommand*)command;
36
+ - (void)silentRestoreAllProducts:(CDVInvokedUrlCommand*)command;
39
37
  - (void)purchasedSubscription:(CDVInvokedUrlCommand*)command;
40
38
  - (void)allProducts:(CDVInvokedUrlCommand*)command;
41
39
  - (void)productWithIdentifier:(CDVInvokedUrlCommand*)command;
@@ -45,10 +43,8 @@
45
43
  - (void)removeEventsListener:(CDVInvokedUrlCommand*)command;
46
44
  - (void)handle:(CDVInvokedUrlCommand*)command;
47
45
  - (void)close:(CDVInvokedUrlCommand*)command;
48
- - (void)setLoginTappedHandler:(CDVInvokedUrlCommand*)command;
49
- - (void)onUserLoggedIn:(CDVInvokedUrlCommand*)command;
50
- - (void)setConfirmPurchaseHandler:(CDVInvokedUrlCommand*)command;
51
- - (void)processToPayment:(CDVInvokedUrlCommand*)command;
52
-
46
+ - (void)setPaywallActionInterceptor:(CDVInvokedUrlCommand*)command;
47
+ - (void)onProcessAction:(CDVInvokedUrlCommand*)command;
48
+ - (void)closePaywall:(CDVInvokedUrlCommand*)command;
53
49
 
54
50
  @end
@@ -15,15 +15,15 @@
15
15
  NSString *apiKey = [command argumentAtIndex:0];
16
16
  NSString *userId = [command argumentAtIndex:2];
17
17
  NSInteger logLevel = [[command argumentAtIndex:3] intValue];
18
- BOOL observerMode = [[command argumentAtIndex:4] boolValue];
19
-
20
- [Purchasely startWithAPIKey:apiKey appUserId:userId observerMode:observerMode eventDelegate:nil uiDelegate:nil confirmPurchaseHandler:nil logLevel:logLevel initialized:^(BOOL initialized, NSError * _Nullable error) {
21
- if (error != nil) {
22
- [self failureFor:command resultString: error.localizedDescription];
23
- } else {
24
- [self successFor:command resultBool:initialized];
25
- }
26
- }];
18
+ NSInteger runningMode = [[command argumentAtIndex:4] intValue];
19
+
20
+ [Purchasely startWithAPIKey:apiKey appUserId:userId runningMode:runningMode eventDelegate:nil uiDelegate:nil paywallActionsInterceptor:nil logLevel:logLevel initialized:^(BOOL initialized, NSError * _Nullable error) {
21
+ if (error != nil) {
22
+ [self failureFor:command resultString: error.localizedDescription];
23
+ } else {
24
+ [self successFor:command resultBool:initialized];
25
+ }
26
+ }];
27
27
  [Purchasely setAppTechnology:PLYAppTechnologyCordova];
28
28
  }
29
29
 
@@ -73,60 +73,66 @@
73
73
  - (void)presentPresentationWithIdentifier:(CDVInvokedUrlCommand*)command {
74
74
  NSString *presentationVendorId = [command argumentAtIndex:0];
75
75
 
76
- UIViewController *ctrl = [Purchasely presentationControllerWith:presentationVendorId completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
77
- NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
78
- [self successFor:command resultDict:resultDict];
79
- }];
76
+ UIViewController *ctrl = [Purchasely presentationControllerWith:presentationVendorId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
77
+ NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
78
+ [self successFor:command resultDict:resultDict];
79
+ }];
80
80
 
81
- UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
82
- [navCtrl.navigationBar setTranslucent:YES];
83
- [navCtrl.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
84
- [navCtrl.navigationBar setShadowImage: [UIImage new]];
85
- [navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
81
+ if (ctrl != nil) {
82
+ UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
83
+ [navCtrl.navigationBar setTranslucent:YES];
84
+ [navCtrl.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
85
+ [navCtrl.navigationBar setShadowImage: [UIImage new]];
86
+ [navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
86
87
 
87
- self.presentedPresentationViewController = navCtrl;
88
+ self.presentedPresentationViewController = navCtrl;
88
89
 
89
- [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
90
+ [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
91
+ }
90
92
  }
91
93
 
92
94
  - (void)presentPlanWithIdentifier:(CDVInvokedUrlCommand*)command {
93
95
  NSString *planVendorId = [command argumentAtIndex:0];
94
96
  NSString *presentationVendorId = [command argumentAtIndex:1];
95
97
 
96
- UIViewController *ctrl = [Purchasely planControllerFor:planVendorId with:presentationVendorId completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
98
+ UIViewController *ctrl = [Purchasely planControllerFor:planVendorId with:presentationVendorId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
97
99
  NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
98
100
  [self successFor:command resultDict:resultDict];
99
101
  }];
100
102
 
101
- UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
102
- [navCtrl.navigationBar setTranslucent:YES];
103
- [navCtrl.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
104
- [navCtrl.navigationBar setShadowImage: [UIImage new]];
105
- [navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
106
-
107
- self.presentedPresentationViewController = navCtrl;
108
-
109
- [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
103
+ if (ctrl != nil) {
104
+ UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
105
+ [navCtrl.navigationBar setTranslucent:YES];
106
+ [navCtrl.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
107
+ [navCtrl.navigationBar setShadowImage: [UIImage new]];
108
+ [navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
109
+
110
+ self.presentedPresentationViewController = navCtrl;
111
+
112
+ [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
113
+ }
110
114
  }
111
115
 
112
116
  - (void)presentProductWithIdentifier:(CDVInvokedUrlCommand*)command {
113
117
  NSString *productVendorId = [command argumentAtIndex:0];
114
118
  NSString *presentationVendorId = [command argumentAtIndex:1];
115
119
 
116
- UIViewController *ctrl = [Purchasely productControllerFor:productVendorId with:presentationVendorId completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
120
+ UIViewController *ctrl = [Purchasely productControllerFor:productVendorId with:presentationVendorId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
117
121
  NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
118
122
  [self successFor:command resultDict:resultDict];
119
123
  }];
120
124
 
121
- UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
122
- [navCtrl.navigationBar setTranslucent:YES];
123
- [navCtrl.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
124
- [navCtrl.navigationBar setShadowImage: [UIImage new]];
125
- [navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
126
-
127
- self.presentedPresentationViewController = navCtrl;
128
-
129
- [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
125
+ if (ctrl != nil) {
126
+ UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
127
+ [navCtrl.navigationBar setTranslucent:YES];
128
+ [navCtrl.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
129
+ [navCtrl.navigationBar setShadowImage: [UIImage new]];
130
+ [navCtrl.navigationBar setTintColor: [UIColor whiteColor]];
131
+
132
+ self.presentedPresentationViewController = navCtrl;
133
+
134
+ [Purchasely showController:navCtrl type: PLYUIControllerTypeProductPage];
135
+ }
130
136
  }
131
137
 
132
138
  - (void)presentSubscriptions:(CDVInvokedUrlCommand*)command {
@@ -263,50 +269,6 @@
263
269
  [Purchasely setLanguageFrom:locale];
264
270
  }
265
271
 
266
- - (void)setLoginTappedHandler:(CDVInvokedUrlCommand*)command {
267
- self.loginTappedCommand = command;
268
- [Purchasely setLoginTappedHandler:^(UIViewController * _Nonnull controller, void (^ _Nonnull closedHandler)(BOOL)) {
269
- self.loginClosedHandler = closedHandler;
270
-
271
- [self.presentedPresentationViewController dismissViewControllerAnimated:true completion:^{
272
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
273
- [result setKeepCallbackAsBool:YES];
274
- [self.commandDelegate sendPluginResult:result callbackId:self.loginTappedCommand.callbackId];
275
- }];
276
- }];
277
- }
278
-
279
- - (void)onUserLoggedIn:(CDVInvokedUrlCommand*)command {
280
- BOOL userDidLogin = [[command argumentAtIndex:0] boolValue];
281
-
282
- [Purchasely showController:self.presentedPresentationViewController type: PLYUIControllerTypeProductPage];
283
- self.loginClosedHandler(userDidLogin);
284
- }
285
-
286
- - (void)setConfirmPurchaseHandler:(CDVInvokedUrlCommand*)command {
287
- self.authorizePurchaseCommand = command;
288
- [Purchasely setConfirmPurchaseHandler:^(UIViewController * _Nonnull controller, void (^ _Nonnull authorizePurchaseHandler)(BOOL)) {
289
- self.authorizePurchaseHandler = authorizePurchaseHandler;
290
-
291
- [self.presentedPresentationViewController dismissViewControllerAnimated:true completion:^{
292
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
293
- [result setKeepCallbackAsBool:YES];
294
- [self.commandDelegate sendPluginResult:result callbackId:self.authorizePurchaseCommand.callbackId];
295
- }];
296
- }];
297
- }
298
-
299
- - (void)processToPayment:(CDVInvokedUrlCommand*)command {
300
- BOOL processToPayment = [[command argumentAtIndex:0] boolValue];
301
-
302
- if (self.presentedPresentationViewController != nil) {
303
- [Purchasely showController:self.presentedPresentationViewController type: PLYUIControllerTypeProductPage];
304
- if (self.authorizePurchaseHandler != nil) {
305
- self.authorizePurchaseHandler(processToPayment);
306
- }
307
- }
308
- }
309
-
310
272
  // Helpers
311
273
 
312
274
  - (NSDictionary<NSString *, NSObject *> *) resultDictionaryForPresentationController:(PLYProductViewControllerResult)result plan:(PLYPlan * _Nullable)plan {
@@ -333,6 +295,99 @@
333
295
  return productViewResult;
334
296
  }
335
297
 
298
+ - (NSDictionary<NSString *, NSObject *> *) resultDictionaryForActionInterceptor:(PLYPresentationAction) action
299
+ parameters: (PLYPresentationActionParameters * _Nullable) params
300
+ presentationInfos: (PLYPresentationInfo * _Nullable) infos {
301
+ NSMutableDictionary<NSString *, NSObject *> *actionInterceptorResult = [NSMutableDictionary new];
302
+
303
+ NSString* actionString;
304
+
305
+ switch (action) {
306
+ case PLYPresentationActionLogin:
307
+ actionString = @"login";
308
+ break;
309
+ case PLYPresentationActionPurchase:
310
+ actionString = @"purchase";
311
+ break;
312
+ case PLYPresentationActionClose:
313
+ actionString = @"close";
314
+ break;
315
+ case PLYPresentationActionRestore:
316
+ actionString = @"restore";
317
+ break;
318
+ case PLYPresentationActionNavigate:
319
+ actionString = @"navigate";
320
+ break;
321
+ case PLYPresentationActionPromoCode:
322
+ actionString = @"promo_code";
323
+ break;
324
+ case PLYPresentationActionOpenPresentation:
325
+ actionString = @"open_presentation";
326
+ break;
327
+ }
328
+
329
+ [actionInterceptorResult setObject:actionString forKey:@"action"];
330
+
331
+ if (infos != nil) {
332
+ NSMutableDictionary<NSString *, NSObject *> *infosResult = [NSMutableDictionary new];
333
+ if (infos.contentId != nil) {
334
+ [infosResult setObject:infos.contentId forKey:@"contentId"];
335
+ }
336
+ if (infos.presentationId != nil) {
337
+ [infosResult setObject:infos.presentationId forKey:@"presentationId"];
338
+ }
339
+ [actionInterceptorResult setObject:infosResult forKey:@"info"];
340
+ }
341
+ if (params != nil) {
342
+ NSMutableDictionary<NSString *, NSObject *> *paramsResult = [NSMutableDictionary new];
343
+ if (params.url != nil) {
344
+ [paramsResult setObject:params.url.absoluteString forKey:@"url"];
345
+ }
346
+ if (params.plan != nil) {
347
+ [paramsResult setObject:[params.plan asDictionary] forKey:@"plan"];
348
+ }
349
+ if (params.title != nil) {
350
+ [paramsResult setObject:params.title forKey:@"title"];
351
+ }
352
+ if (params.presentation != nil) {
353
+ [paramsResult setObject:params.presentation forKey:@"presentation"];
354
+ }
355
+ [actionInterceptorResult setObject:paramsResult forKey:@"parameters"];
356
+ }
357
+
358
+ return actionInterceptorResult;
359
+ }
360
+
361
+ - (void)setPaywallActionInterceptor:(CDVInvokedUrlCommand*)command {
362
+ self.paywallActionInterceptorCommand = command;
363
+ [Purchasely setPaywallActionsInterceptor:^(enum PLYPresentationAction action, PLYPresentationActionParameters * _Nullable parameters, PLYPresentationInfo * _Nullable infos, void (^ _Nonnull onProcessActionHandler)(BOOL)) {
364
+ self.onProcessActionHandler = onProcessActionHandler;
365
+ NSDictionary *resultDict = [self resultDictionaryForActionInterceptor:action parameters:parameters presentationInfos:infos];
366
+
367
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultDict];
368
+ [pluginResult setKeepCallbackAsBool:YES];
369
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:self.paywallActionInterceptorCommand.callbackId];
370
+
371
+ }];
372
+ }
373
+
374
+ - (void)onProcessAction:(CDVInvokedUrlCommand*)command {
375
+ BOOL processAction = [[command argumentAtIndex:0] boolValue];
376
+ if (self.onProcessActionHandler != nil) {
377
+ self.onProcessActionHandler(processAction);
378
+ }
379
+ }
380
+
381
+ - (void)closePaywall:(CDVInvokedUrlCommand*)command {
382
+ if (self.presentedPresentationViewController != nil) {
383
+ dispatch_async(dispatch_get_main_queue(), ^{
384
+ [self.presentedPresentationViewController dismissViewControllerAnimated:true completion:^{
385
+ self.presentedPresentationViewController = nil;
386
+ }];
387
+ });
388
+ }
389
+ }
390
+
336
391
  - (void)successFor:(CDVInvokedUrlCommand *)command {
337
392
  CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
338
393
  [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
@@ -25,6 +25,10 @@
25
25
  [dict setObject:self.name forKey:@"name"];
26
26
  }
27
27
 
28
+ if (self.appleProductId != nil) {
29
+ [dict setObject:self.appleProductId forKey:@"appleProductId"];
30
+ }
31
+
28
32
  NSString *price = [self localizedFullPriceWithLanguage:nil];
29
33
  if (price != nil) {
30
34
  [dict setObject:price forKey:@"price"];
package/www/Purchasely.js CHANGED
@@ -2,8 +2,8 @@ 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, observerMode, success, error) {
6
- exec(success, error, 'Purchasely', 'startWithAPIKey', [apiKey, stores, userId, logLevel, observerMode]);
5
+ exports.startWithAPIKey = function (apiKey, stores, userId, logLevel, runningMode, success, error) {
6
+ exec(success, error, 'Purchasely', 'startWithAPIKey', [apiKey, stores, userId, logLevel, runningMode]);
7
7
  };
8
8
 
9
9
  exports.addEventsListener = function (success, error) {
@@ -110,20 +110,16 @@ exports.productWithIdentifier = function (productId, success) {
110
110
  exec(success, defaultError, 'Purchasely', 'productWithIdentifier', [productId]);
111
111
  };
112
112
 
113
- exports.setLoginTappedHandler = function (success) {
114
- exec(success, defaultError, 'Purchasely', 'setLoginTappedHandler', []);
113
+ exports.setPaywallActionInterceptor = function (success) {
114
+ exec(success, defaultError, 'Purchasely', 'setPaywallActionInterceptor', []);
115
115
  };
116
116
 
117
- exports.onUserLoggedIn = function (userLoggedIn) {
118
- exec(() => {}, defaultError, 'Purchasely', 'onUserLoggedIn', [userLoggedIn]);
117
+ exports.onProcessAction = function (processAction) {
118
+ exec(() => {}, defaultError, 'Purchasely', 'onProcessAction', [processAction]);
119
119
  };
120
120
 
121
- exports.setConfirmPurchaseHandler = function (success) {
122
- exec(success, defaultError, 'Purchasely', 'setConfirmPurchaseHandler', []);
123
- };
124
-
125
- exports.processToPayment = function (processToPayment) {
126
- exec(() => {}, defaultError, 'Purchasely', 'processToPayment', [processToPayment]);
121
+ exports.closePaywall = function () {
122
+ exec(() => {}, defaultError, 'Purchasely', 'closePaywall', []);
127
123
  };
128
124
 
129
125
  exports.userSubscriptions = function (success, error) {
@@ -169,3 +165,22 @@ exports.PlanType = {
169
165
  nonRenewingSubscription: 3,
170
166
  unknown: 4
171
167
  }
168
+
169
+
170
+ exports.RunningMode = {
171
+ transactionOnly: 0,
172
+ observer: 1,
173
+ paywallOnly: 2,
174
+ paywallObserver: 3,
175
+ full: 4
176
+ }
177
+
178
+ exports.PaywallAction = {
179
+ close: 'close',
180
+ login: 'login',
181
+ navigate: 'navigate',
182
+ purchase: 'purchase',
183
+ restore: 'restore',
184
+ open_presentation: 'open_presentation',
185
+ promo_code: 'promo_code',
186
+ }