@purchasely/cordova-plugin-purchasely 2.1.0 → 2.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 +4 -1
- package/example/package-lock.json +48 -79
- package/example/package.json +1 -4
- package/example/www/js/index.js +4 -4
- package/package.json +1 -1
- package/plugin.xml +3 -3
- package/src/android/PurchaselyPlugin.java +33 -20
- package/src/ios/CDVPurchasely.m +167 -157
- package/www/Purchasely.js +11 -2
package/VERSIONS.md
CHANGED
|
@@ -16,4 +16,7 @@ This file provides the underlying native SDK versions that the Cordova SDK relie
|
|
|
16
16
|
| 1.2.0 | 2.8.0 | 2.8.0 |
|
|
17
17
|
| 2.0.0 | 3.0.0 | 3.0.1 |
|
|
18
18
|
| 2.0.1 | 3.0.0 | 3.0.1 |
|
|
19
|
-
| 2.1.0 | 3.1.0 | 3.1.0 |
|
|
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 |
|
|
@@ -9,16 +9,14 @@
|
|
|
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.0",
|
|
14
13
|
"cordova-ios": "^6.2.0",
|
|
15
|
-
"cordova-plugin-purchasely": "file:.."
|
|
16
|
-
"cordova-plugin-whitelist": "^1.3.5"
|
|
14
|
+
"cordova-plugin-purchasely": "file:.."
|
|
17
15
|
}
|
|
18
16
|
},
|
|
19
17
|
"..": {
|
|
20
18
|
"name": "cordova-plugin-purchasely",
|
|
21
|
-
"version": "2.
|
|
19
|
+
"version": "2.2.1",
|
|
22
20
|
"dev": true,
|
|
23
21
|
"license": "ISC"
|
|
24
22
|
},
|
|
@@ -68,10 +66,6 @@
|
|
|
68
66
|
"node": ">= 8"
|
|
69
67
|
}
|
|
70
68
|
},
|
|
71
|
-
"node_modules/@purchasely/cordova-plugin-purchasely": {
|
|
72
|
-
"resolved": "..",
|
|
73
|
-
"link": true
|
|
74
|
-
},
|
|
75
69
|
"node_modules/abbrev": {
|
|
76
70
|
"version": "1.1.1",
|
|
77
71
|
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
|
|
@@ -227,9 +221,9 @@
|
|
|
227
221
|
}
|
|
228
222
|
},
|
|
229
223
|
"node_modules/cordova-android/node_modules/fs-extra": {
|
|
230
|
-
"version": "10.0.
|
|
231
|
-
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.
|
|
232
|
-
"integrity": "sha512-
|
|
224
|
+
"version": "10.0.1",
|
|
225
|
+
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz",
|
|
226
|
+
"integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==",
|
|
233
227
|
"dev": true,
|
|
234
228
|
"dependencies": {
|
|
235
229
|
"graceful-fs": "^4.2.0",
|
|
@@ -290,22 +284,6 @@
|
|
|
290
284
|
"resolved": "..",
|
|
291
285
|
"link": true
|
|
292
286
|
},
|
|
293
|
-
"node_modules/cordova-plugin-whitelist": {
|
|
294
|
-
"version": "1.3.5",
|
|
295
|
-
"resolved": "https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.5.tgz",
|
|
296
|
-
"integrity": "sha512-+v/VzCYBdGsIxJTP2m+RWaq7l/NLu7b976w6XGJUFiN2TVOeaGrytaR4jRy0w9akRai8uKFeBmuGHmlS/sOeCA==",
|
|
297
|
-
"dev": true,
|
|
298
|
-
"engines": {
|
|
299
|
-
"cordovaDependencies": {
|
|
300
|
-
"0.0.0": {
|
|
301
|
-
"cordova-android": ">=4.0.0"
|
|
302
|
-
},
|
|
303
|
-
"1.3.5": {
|
|
304
|
-
"cordova-android": ">=4.0.0 <10.0.0"
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
},
|
|
309
287
|
"node_modules/cross-spawn": {
|
|
310
288
|
"version": "7.0.3",
|
|
311
289
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
|
@@ -587,9 +565,9 @@
|
|
|
587
565
|
}
|
|
588
566
|
},
|
|
589
567
|
"node_modules/is-core-module": {
|
|
590
|
-
"version": "2.
|
|
591
|
-
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.
|
|
592
|
-
"integrity": "sha512
|
|
568
|
+
"version": "2.9.0",
|
|
569
|
+
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz",
|
|
570
|
+
"integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==",
|
|
593
571
|
"dev": true,
|
|
594
572
|
"dependencies": {
|
|
595
573
|
"has": "^1.0.3"
|
|
@@ -855,9 +833,9 @@
|
|
|
855
833
|
}
|
|
856
834
|
},
|
|
857
835
|
"node_modules/plist": {
|
|
858
|
-
"version": "3.0.
|
|
859
|
-
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.
|
|
860
|
-
"integrity": "sha512-
|
|
836
|
+
"version": "3.0.5",
|
|
837
|
+
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.5.tgz",
|
|
838
|
+
"integrity": "sha512-83vX4eYdQp3vP9SxuYgEM/G/pJQqLUz/V/xzPrzruLs7fz7jxGQ1msZ/mg1nwZxUSuOp4sb+/bEIbRrbzZRxDA==",
|
|
861
839
|
"dev": true,
|
|
862
840
|
"dependencies": {
|
|
863
841
|
"base64-js": "^1.5.1",
|
|
@@ -1044,15 +1022,15 @@
|
|
|
1044
1022
|
}
|
|
1045
1023
|
},
|
|
1046
1024
|
"node_modules/signal-exit": {
|
|
1047
|
-
"version": "3.0.
|
|
1048
|
-
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.
|
|
1049
|
-
"integrity": "sha512-
|
|
1025
|
+
"version": "3.0.7",
|
|
1026
|
+
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
|
|
1027
|
+
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
|
|
1050
1028
|
"dev": true
|
|
1051
1029
|
},
|
|
1052
1030
|
"node_modules/simctl": {
|
|
1053
|
-
"version": "2.0.
|
|
1054
|
-
"resolved": "https://registry.npmjs.org/simctl/-/simctl-2.0.
|
|
1055
|
-
"integrity": "sha512-
|
|
1031
|
+
"version": "2.0.3",
|
|
1032
|
+
"resolved": "https://registry.npmjs.org/simctl/-/simctl-2.0.3.tgz",
|
|
1033
|
+
"integrity": "sha512-kKCak0yszxHae5eVWcmrjV3ouUGac3sjlhjdLWpyPu4eiQcWoHsCrqS34kkgzHN8Ystqkh/LFjzrldk/g3BYJg==",
|
|
1056
1034
|
"dev": true,
|
|
1057
1035
|
"dependencies": {
|
|
1058
1036
|
"shelljs": "^0.8.5",
|
|
@@ -1060,20 +1038,20 @@
|
|
|
1060
1038
|
}
|
|
1061
1039
|
},
|
|
1062
1040
|
"node_modules/simple-plist": {
|
|
1063
|
-
"version": "1.3.
|
|
1064
|
-
"resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.3.
|
|
1065
|
-
"integrity": "sha512-
|
|
1041
|
+
"version": "1.3.1",
|
|
1042
|
+
"resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.3.1.tgz",
|
|
1043
|
+
"integrity": "sha512-iMSw5i0XseMnrhtIzRb7XpQEXepa9xhWxGUojHBL43SIpQuDQkh3Wpy67ZbDzZVr6EKxvwVChnVpdl8hEVLDiw==",
|
|
1066
1044
|
"dev": true,
|
|
1067
1045
|
"dependencies": {
|
|
1068
1046
|
"bplist-creator": "0.1.0",
|
|
1069
|
-
"bplist-parser": "0.3.
|
|
1070
|
-
"plist": "^3.0.
|
|
1047
|
+
"bplist-parser": "0.3.1",
|
|
1048
|
+
"plist": "^3.0.5"
|
|
1071
1049
|
}
|
|
1072
1050
|
},
|
|
1073
1051
|
"node_modules/simple-plist/node_modules/bplist-parser": {
|
|
1074
|
-
"version": "0.3.
|
|
1075
|
-
"resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.
|
|
1076
|
-
"integrity": "sha512-
|
|
1052
|
+
"version": "0.3.1",
|
|
1053
|
+
"resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.1.tgz",
|
|
1054
|
+
"integrity": "sha512-PyJxiNtA5T2PlLIeBot4lbp7rj4OadzjnMZD/G5zuBNt8ei/yCU7+wW0h2bag9vr8c+/WuRWmSxbqAl9hL1rBA==",
|
|
1077
1055
|
"dev": true,
|
|
1078
1056
|
"dependencies": {
|
|
1079
1057
|
"big-integer": "1.6.x"
|
|
@@ -1298,9 +1276,6 @@
|
|
|
1298
1276
|
"fastq": "^1.6.0"
|
|
1299
1277
|
}
|
|
1300
1278
|
},
|
|
1301
|
-
"@purchasely/cordova-plugin-purchasely": {
|
|
1302
|
-
"version": "file:.."
|
|
1303
|
-
},
|
|
1304
1279
|
"abbrev": {
|
|
1305
1280
|
"version": "1.1.1",
|
|
1306
1281
|
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
|
|
@@ -1423,9 +1398,9 @@
|
|
|
1423
1398
|
},
|
|
1424
1399
|
"dependencies": {
|
|
1425
1400
|
"fs-extra": {
|
|
1426
|
-
"version": "10.0.
|
|
1427
|
-
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.
|
|
1428
|
-
"integrity": "sha512-
|
|
1401
|
+
"version": "10.0.1",
|
|
1402
|
+
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz",
|
|
1403
|
+
"integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==",
|
|
1429
1404
|
"dev": true,
|
|
1430
1405
|
"requires": {
|
|
1431
1406
|
"graceful-fs": "^4.2.0",
|
|
@@ -1478,12 +1453,6 @@
|
|
|
1478
1453
|
"cordova-plugin-purchasely": {
|
|
1479
1454
|
"version": "file:.."
|
|
1480
1455
|
},
|
|
1481
|
-
"cordova-plugin-whitelist": {
|
|
1482
|
-
"version": "1.3.5",
|
|
1483
|
-
"resolved": "https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.5.tgz",
|
|
1484
|
-
"integrity": "sha512-+v/VzCYBdGsIxJTP2m+RWaq7l/NLu7b976w6XGJUFiN2TVOeaGrytaR4jRy0w9akRai8uKFeBmuGHmlS/sOeCA==",
|
|
1485
|
-
"dev": true
|
|
1486
|
-
},
|
|
1487
1456
|
"cross-spawn": {
|
|
1488
1457
|
"version": "7.0.3",
|
|
1489
1458
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
|
@@ -1707,9 +1676,9 @@
|
|
|
1707
1676
|
}
|
|
1708
1677
|
},
|
|
1709
1678
|
"is-core-module": {
|
|
1710
|
-
"version": "2.
|
|
1711
|
-
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.
|
|
1712
|
-
"integrity": "sha512
|
|
1679
|
+
"version": "2.9.0",
|
|
1680
|
+
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz",
|
|
1681
|
+
"integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==",
|
|
1713
1682
|
"dev": true,
|
|
1714
1683
|
"requires": {
|
|
1715
1684
|
"has": "^1.0.3"
|
|
@@ -1901,9 +1870,9 @@
|
|
|
1901
1870
|
"dev": true
|
|
1902
1871
|
},
|
|
1903
1872
|
"plist": {
|
|
1904
|
-
"version": "3.0.
|
|
1905
|
-
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.
|
|
1906
|
-
"integrity": "sha512-
|
|
1873
|
+
"version": "3.0.5",
|
|
1874
|
+
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.5.tgz",
|
|
1875
|
+
"integrity": "sha512-83vX4eYdQp3vP9SxuYgEM/G/pJQqLUz/V/xzPrzruLs7fz7jxGQ1msZ/mg1nwZxUSuOp4sb+/bEIbRrbzZRxDA==",
|
|
1907
1876
|
"dev": true,
|
|
1908
1877
|
"requires": {
|
|
1909
1878
|
"base64-js": "^1.5.1",
|
|
@@ -2018,15 +1987,15 @@
|
|
|
2018
1987
|
}
|
|
2019
1988
|
},
|
|
2020
1989
|
"signal-exit": {
|
|
2021
|
-
"version": "3.0.
|
|
2022
|
-
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.
|
|
2023
|
-
"integrity": "sha512-
|
|
1990
|
+
"version": "3.0.7",
|
|
1991
|
+
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
|
|
1992
|
+
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
|
|
2024
1993
|
"dev": true
|
|
2025
1994
|
},
|
|
2026
1995
|
"simctl": {
|
|
2027
|
-
"version": "2.0.
|
|
2028
|
-
"resolved": "https://registry.npmjs.org/simctl/-/simctl-2.0.
|
|
2029
|
-
"integrity": "sha512-
|
|
1996
|
+
"version": "2.0.3",
|
|
1997
|
+
"resolved": "https://registry.npmjs.org/simctl/-/simctl-2.0.3.tgz",
|
|
1998
|
+
"integrity": "sha512-kKCak0yszxHae5eVWcmrjV3ouUGac3sjlhjdLWpyPu4eiQcWoHsCrqS34kkgzHN8Ystqkh/LFjzrldk/g3BYJg==",
|
|
2030
1999
|
"dev": true,
|
|
2031
2000
|
"requires": {
|
|
2032
2001
|
"shelljs": "^0.8.5",
|
|
@@ -2034,20 +2003,20 @@
|
|
|
2034
2003
|
}
|
|
2035
2004
|
},
|
|
2036
2005
|
"simple-plist": {
|
|
2037
|
-
"version": "1.3.
|
|
2038
|
-
"resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.3.
|
|
2039
|
-
"integrity": "sha512-
|
|
2006
|
+
"version": "1.3.1",
|
|
2007
|
+
"resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.3.1.tgz",
|
|
2008
|
+
"integrity": "sha512-iMSw5i0XseMnrhtIzRb7XpQEXepa9xhWxGUojHBL43SIpQuDQkh3Wpy67ZbDzZVr6EKxvwVChnVpdl8hEVLDiw==",
|
|
2040
2009
|
"dev": true,
|
|
2041
2010
|
"requires": {
|
|
2042
2011
|
"bplist-creator": "0.1.0",
|
|
2043
|
-
"bplist-parser": "0.3.
|
|
2044
|
-
"plist": "^3.0.
|
|
2012
|
+
"bplist-parser": "0.3.1",
|
|
2013
|
+
"plist": "^3.0.5"
|
|
2045
2014
|
},
|
|
2046
2015
|
"dependencies": {
|
|
2047
2016
|
"bplist-parser": {
|
|
2048
|
-
"version": "0.3.
|
|
2049
|
-
"resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.
|
|
2050
|
-
"integrity": "sha512-
|
|
2017
|
+
"version": "0.3.1",
|
|
2018
|
+
"resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.1.tgz",
|
|
2019
|
+
"integrity": "sha512-PyJxiNtA5T2PlLIeBot4lbp7rj4OadzjnMZD/G5zuBNt8ei/yCU7+wW0h2bag9vr8c+/WuRWmSxbqAl9hL1rBA==",
|
|
2051
2020
|
"dev": true,
|
|
2052
2021
|
"requires": {
|
|
2053
2022
|
"big-integer": "1.6.x"
|
package/example/package.json
CHANGED
|
@@ -13,15 +13,12 @@
|
|
|
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.0",
|
|
18
17
|
"cordova-ios": "^6.2.0",
|
|
19
|
-
"cordova-plugin-purchasely": "file:.."
|
|
20
|
-
"cordova-plugin-whitelist": "^1.3.5"
|
|
18
|
+
"cordova-plugin-purchasely": "file:.."
|
|
21
19
|
},
|
|
22
20
|
"cordova": {
|
|
23
21
|
"plugins": {
|
|
24
|
-
"cordova-plugin-whitelist": {},
|
|
25
22
|
"cordova-plugin-purchasely": {}
|
|
26
23
|
},
|
|
27
24
|
"platforms": [
|
package/example/www/js/index.js
CHANGED
|
@@ -156,10 +156,10 @@ function onPuchaselySdkReady() {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
function openPresentation() {
|
|
159
|
-
Purchasely.
|
|
160
|
-
|
|
161
|
-
null,
|
|
162
|
-
true,
|
|
159
|
+
Purchasely.presentPresentationForPlacement(
|
|
160
|
+
'onboarding', //placementId
|
|
161
|
+
null, //contentId
|
|
162
|
+
true, //fullscreen
|
|
163
163
|
(callback) => {
|
|
164
164
|
console.log(callback);
|
|
165
165
|
if(callback.result == Purchasely.PurchaseResult.CANCELLED) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purchasely/cordova-plugin-purchasely",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.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="2.1
|
|
2
|
+
<plugin id="@purchasely/cordova-plugin-purchasely" version="2.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="3.1
|
|
31
|
+
<pod name="Purchasely" spec="3.2.1"/>
|
|
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:3.1
|
|
54
|
+
<framework src="io.purchasely:core:3.2.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" />
|
|
@@ -73,11 +73,12 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
73
73
|
switch (action) {
|
|
74
74
|
case "startWithAPIKey":
|
|
75
75
|
startWithAPIKey(
|
|
76
|
-
args.getString(0),
|
|
76
|
+
getStringFromJson(args.getString(0)),
|
|
77
77
|
args.getJSONArray(1),
|
|
78
|
-
args.getString(2),
|
|
78
|
+
getStringFromJson(args.getString(2)),
|
|
79
79
|
args.getInt(3),
|
|
80
80
|
args.getInt(4),
|
|
81
|
+
getStringFromJson(args.getString(5)),
|
|
81
82
|
callbackContext);
|
|
82
83
|
break;
|
|
83
84
|
case "close":
|
|
@@ -93,19 +94,19 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
93
94
|
getAnonymousUserId(callbackContext);
|
|
94
95
|
break;
|
|
95
96
|
case "userLogin":
|
|
96
|
-
userLogin(args.getString(0), callbackContext);
|
|
97
|
+
userLogin(getStringFromJson(args.getString(0)), callbackContext);
|
|
97
98
|
break;
|
|
98
99
|
case "userLogout":
|
|
99
100
|
userLogout();
|
|
100
101
|
break;
|
|
101
102
|
case "setLanguage":
|
|
102
|
-
setLanguage(args.getString(0));
|
|
103
|
+
setLanguage(getStringFromJson(args.getString(0)));
|
|
103
104
|
break;
|
|
104
105
|
case "setLogLevel":
|
|
105
106
|
setLogLevel(args.getInt(0));
|
|
106
107
|
break;
|
|
107
108
|
case "setAttribute":
|
|
108
|
-
setAttribute(args.getInt(0), args.getString(1));
|
|
109
|
+
setAttribute(args.getInt(0), getStringFromJson(args.getString(1)));
|
|
109
110
|
break;
|
|
110
111
|
case "setDefaultPresentationResultHandler":
|
|
111
112
|
setDefaultPresentationResultHandler(callbackContext);
|
|
@@ -121,34 +122,34 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
121
122
|
break;
|
|
122
123
|
case "presentPresentationWithIdentifier":
|
|
123
124
|
presentPresentationWithIdentifier(
|
|
124
|
-
args.getString(0),
|
|
125
|
-
args.getString(1),
|
|
125
|
+
getStringFromJson(args.getString(0)),
|
|
126
|
+
getStringFromJson(args.getString(1)),
|
|
126
127
|
args.getBoolean(2),
|
|
127
128
|
callbackContext
|
|
128
129
|
);
|
|
129
130
|
break;
|
|
130
131
|
case "presentPresentationForPlacement":
|
|
131
132
|
presentPresentationForPlacement(
|
|
132
|
-
args.getString(0),
|
|
133
|
-
args.getString(1),
|
|
133
|
+
getStringFromJson(args.getString(0)),
|
|
134
|
+
getStringFromJson(args.getString(1)),
|
|
134
135
|
args.getBoolean(2),
|
|
135
136
|
callbackContext
|
|
136
137
|
);
|
|
137
138
|
break;
|
|
138
139
|
case "presentProductWithIdentifier":
|
|
139
140
|
presentProductWithIdentifier(
|
|
140
|
-
args.getString(0),
|
|
141
|
-
args.getString(1),
|
|
142
|
-
args.getString(2),
|
|
141
|
+
getStringFromJson(args.getString(0)),
|
|
142
|
+
getStringFromJson(args.getString(1)),
|
|
143
|
+
getStringFromJson(args.getString(2)),
|
|
143
144
|
args.getBoolean(3),
|
|
144
145
|
callbackContext
|
|
145
146
|
);
|
|
146
147
|
break;
|
|
147
148
|
case "presentPlanWithIdentifier":
|
|
148
149
|
presentPlanWithIdentifier(
|
|
149
|
-
args.getString(0),
|
|
150
|
-
args.getString(1),
|
|
151
|
-
args.getString(2),
|
|
150
|
+
getStringFromJson(args.getString(0)),
|
|
151
|
+
getStringFromJson(args.getString(1)),
|
|
152
|
+
getStringFromJson(args.getString(2)),
|
|
152
153
|
args.getBoolean(3),
|
|
153
154
|
callbackContext
|
|
154
155
|
);
|
|
@@ -166,21 +167,21 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
166
167
|
userSubscriptions(callbackContext);
|
|
167
168
|
break;
|
|
168
169
|
case "handle":
|
|
169
|
-
handle(args.getString(0), callbackContext);
|
|
170
|
+
handle(getStringFromJson(args.getString(0)), callbackContext);
|
|
170
171
|
break;
|
|
171
172
|
case "allProducts":
|
|
172
173
|
allProducts(callbackContext);
|
|
173
174
|
break;
|
|
174
175
|
case "productWithIdentifier":
|
|
175
|
-
productWithIdentifier(args.getString(0), callbackContext);
|
|
176
|
+
productWithIdentifier(getStringFromJson(args.getString(0)), callbackContext);
|
|
176
177
|
break;
|
|
177
178
|
case "planWithIdentifier":
|
|
178
|
-
planWithIdentifier(args.getString(0), callbackContext);
|
|
179
|
+
planWithIdentifier(getStringFromJson(args.getString(0)), callbackContext);
|
|
179
180
|
break;
|
|
180
181
|
case "purchaseWithPlanVendorId":
|
|
181
182
|
purchaseWithPlanVendorId(
|
|
182
|
-
args.getString(0),
|
|
183
|
-
args.getString(1),
|
|
183
|
+
getStringFromJson(args.getString(0)),
|
|
184
|
+
getStringFromJson(args.getString(1)),
|
|
184
185
|
callbackContext
|
|
185
186
|
);
|
|
186
187
|
break;
|
|
@@ -203,6 +204,14 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
203
204
|
return true;
|
|
204
205
|
}
|
|
205
206
|
|
|
207
|
+
private String getStringFromJson(String value) {
|
|
208
|
+
if(value == null || value.equals("null") || value.isEmpty()) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
|
|
206
215
|
public static void sendPurchaseResult(PLYProductViewResult result, PLYPlan plan) {
|
|
207
216
|
int productViewResult = 0;
|
|
208
217
|
if(result == PLYProductViewResult.PURCHASED) {
|
|
@@ -232,6 +241,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
232
241
|
String userId,
|
|
233
242
|
int logLevel,
|
|
234
243
|
int runningMode,
|
|
244
|
+
String cordovaSdkVersion,
|
|
235
245
|
CallbackContext callbackContext) {
|
|
236
246
|
ArrayList<String> list = new ArrayList<>();
|
|
237
247
|
for (int i=0; i< stores.length(); i++) {
|
|
@@ -257,6 +267,7 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
257
267
|
.logLevel(LogLevel.values()[logLevel])
|
|
258
268
|
.build();
|
|
259
269
|
|
|
270
|
+
Purchasely.setSdkBridgeVersion(cordovaSdkVersion);
|
|
260
271
|
Purchasely.setAppTechnology(PLYAppTechnology.CORDOVA);
|
|
261
272
|
|
|
262
273
|
Purchasely.start((isConfigured, error) -> {
|
|
@@ -591,6 +602,8 @@ public class PurchaselyPlugin extends CordovaPlugin {
|
|
|
591
602
|
if(info.getContentId() != null) infoMap.put("contentId", info.getContentId());
|
|
592
603
|
if(info.getPresentationId() != null) infoMap.put("presentationId", info.getPresentationId());
|
|
593
604
|
if(info.getPlacementId() != null) infoMap.put("placementId", info.getPlacementId());
|
|
605
|
+
if(info.getAbTestId() != null) infoMap.put("abTestId", info.getAbTestId());
|
|
606
|
+
if(info.getAbTestVariantId() != null) infoMap.put("abTestVariantId", info.getAbTestVariantId());
|
|
594
607
|
|
|
595
608
|
HashMap<String, Object> resultForCordova = new HashMap<>();
|
|
596
609
|
resultForCordova.put("info", infoMap);
|
package/src/ios/CDVPurchasely.m
CHANGED
|
@@ -12,12 +12,15 @@
|
|
|
12
12
|
@implementation CDVPurchasely
|
|
13
13
|
|
|
14
14
|
- (void)startWithAPIKey:(CDVInvokedUrlCommand*)command {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
NSString *apiKey = [command argumentAtIndex:0];
|
|
16
|
+
NSString *userId = [command argumentAtIndex:2];
|
|
17
|
+
NSInteger logLevel = [[command argumentAtIndex:3] intValue];
|
|
18
|
+
NSInteger runningMode = [[command argumentAtIndex:4] intValue];
|
|
19
|
+
NSString *purchaselySdkVersion = [command argumentAtIndex:5];
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
[Purchasely setSdkBridgeVersion:purchaselySdkVersion];
|
|
22
|
+
|
|
23
|
+
[Purchasely setAppTechnology:PLYAppTechnologyCordova];
|
|
21
24
|
[Purchasely startWithAPIKey:apiKey appUserId:userId runningMode:runningMode eventDelegate:nil uiDelegate:nil paywallActionsInterceptor:nil logLevel:logLevel initialized:^(BOOL initialized, NSError * _Nullable error) {
|
|
22
25
|
if (error != nil) {
|
|
23
26
|
[self failureFor:command resultString: error.localizedDescription];
|
|
@@ -28,50 +31,50 @@
|
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
- (void)setLogLevel:(CDVInvokedUrlCommand*)command {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
NSInteger logLevel = [[command argumentAtIndex:0] intValue];
|
|
35
|
+
[Purchasely setLogLevel:logLevel];
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
- (void)userLogin:(CDVInvokedUrlCommand*)command {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
NSString *userId = [command argumentAtIndex:0];
|
|
40
|
+
[Purchasely userLoginWith:userId shouldRefresh:^(BOOL refresh) {
|
|
41
|
+
[self successFor:command resultBool:refresh];
|
|
42
|
+
}];
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
- (void)userLogout:(CDVInvokedUrlCommand*)command {
|
|
43
|
-
|
|
46
|
+
[Purchasely userLogout];
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
- (void)setAttribute:(CDVInvokedUrlCommand*)command {
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
NSInteger attribute = [[command argumentAtIndex:0] intValue];
|
|
51
|
+
NSString *value = [command argumentAtIndex:1];
|
|
49
52
|
|
|
50
|
-
|
|
53
|
+
[Purchasely setAttribute:attribute value:value];
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
- (void)getAnonymousUserId:(CDVInvokedUrlCommand*)command {
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
NSString *anonymousId = [Purchasely anonymousUserId];
|
|
58
|
+
[self successFor:command resultString:anonymousId];
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
- (void)isReadyToPurchase:(CDVInvokedUrlCommand*)command {
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
BOOL isReadyToPurchase = [[command argumentAtIndex:0] boolValue];
|
|
63
|
+
[Purchasely isReadyToPurchase: isReadyToPurchase];
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
- (void)setDefaultPresentationResultHandler:(CDVInvokedUrlCommand*)command {
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
[Purchasely setDefaultPresentationResultHandler:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
68
|
+
NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultDict];
|
|
71
|
+
[pluginResult setKeepCallbackAsBool:YES];
|
|
72
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
73
|
+
}];
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
- (void)presentPresentationWithIdentifier:(CDVInvokedUrlCommand*)command {
|
|
74
|
-
|
|
77
|
+
NSString *presentationVendorId = [command argumentAtIndex:0];
|
|
75
78
|
NSString *contentId = [command argumentAtIndex:1];
|
|
76
79
|
BOOL isFullscreen = [[command argumentAtIndex:2] boolValue];
|
|
77
80
|
|
|
@@ -123,15 +126,15 @@
|
|
|
123
126
|
}
|
|
124
127
|
|
|
125
128
|
- (void)presentPlanWithIdentifier:(CDVInvokedUrlCommand*)command {
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
NSString *planVendorId = [command argumentAtIndex:0];
|
|
130
|
+
NSString *presentationVendorId = [command argumentAtIndex:1];
|
|
128
131
|
NSString *contentId = [command argumentAtIndex:2];
|
|
129
132
|
BOOL isFullscreen = [[command argumentAtIndex:3] boolValue];
|
|
130
133
|
|
|
131
134
|
UIViewController *ctrl = [Purchasely planControllerFor:planVendorId with:presentationVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
|
|
136
|
+
[self successFor:command resultDict:resultDict];
|
|
137
|
+
}];
|
|
135
138
|
|
|
136
139
|
if (ctrl != nil) {
|
|
137
140
|
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
|
|
@@ -150,15 +153,15 @@
|
|
|
150
153
|
}
|
|
151
154
|
|
|
152
155
|
- (void)presentProductWithIdentifier:(CDVInvokedUrlCommand*)command {
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
NSString *productVendorId = [command argumentAtIndex:0];
|
|
157
|
+
NSString *presentationVendorId = [command argumentAtIndex:1];
|
|
155
158
|
NSString *contentId = [command argumentAtIndex:2];
|
|
156
159
|
BOOL isFullscreen = [[command argumentAtIndex:3] boolValue];
|
|
157
160
|
|
|
158
161
|
UIViewController *ctrl = [Purchasely productControllerFor:productVendorId with:presentationVendorId contentId:contentId loaded:nil completion:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
+
NSDictionary *resultDict = [self resultDictionaryForPresentationController:result plan:plan];
|
|
163
|
+
[self successFor:command resultDict:resultDict];
|
|
164
|
+
}];
|
|
162
165
|
|
|
163
166
|
if (ctrl != nil) {
|
|
164
167
|
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
|
|
@@ -177,163 +180,163 @@
|
|
|
177
180
|
}
|
|
178
181
|
|
|
179
182
|
- (void)presentSubscriptions:(CDVInvokedUrlCommand*)command {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
+
UIViewController *ctrl = [Purchasely subscriptionsController];
|
|
184
|
+
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
|
|
185
|
+
ctrl.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target:navCtrl action:@selector(close)];
|
|
183
186
|
|
|
184
|
-
|
|
187
|
+
[Purchasely showController:navCtrl type: PLYUIControllerTypeSubscriptionList];
|
|
185
188
|
}
|
|
186
189
|
|
|
187
190
|
- (void)purchaseWithPlanVendorId:(CDVInvokedUrlCommand*)command {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
191
|
+
NSString *planVendorId = [command argumentAtIndex:0];
|
|
192
|
+
|
|
193
|
+
[Purchasely planWith:planVendorId
|
|
194
|
+
success:^(PLYPlan * _Nonnull plan) {
|
|
195
|
+
[Purchasely purchaseWithPlan:plan
|
|
196
|
+
success:^{
|
|
197
|
+
[self successFor:command resultDict: plan.asDictionary];
|
|
198
|
+
}
|
|
199
|
+
failure:^(NSError * _Nonnull error) {
|
|
200
|
+
[self failureFor:command resultString: error.localizedDescription];
|
|
201
|
+
}];
|
|
202
|
+
}
|
|
203
|
+
failure:^(NSError * _Nullable error) {
|
|
204
|
+
[self failureFor:command resultString: error.localizedDescription];
|
|
205
|
+
}];
|
|
203
206
|
}
|
|
204
207
|
|
|
205
208
|
- (void)restoreAllProducts:(CDVInvokedUrlCommand*)command {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
[Purchasely restoreAllProductsWithSuccess:^{
|
|
210
|
+
[self successFor:command];
|
|
211
|
+
} failure:^(NSError * _Nonnull error) {
|
|
212
|
+
[self failureFor:command resultString:error.localizedDescription];
|
|
213
|
+
}];
|
|
211
214
|
}
|
|
212
215
|
|
|
213
216
|
- (void)silentRestoreAllProducts:(CDVInvokedUrlCommand*)command {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
[Purchasely silentRestoreAllProductsWithSuccess:^{
|
|
218
|
+
[self successFor:command];
|
|
219
|
+
} failure:^(NSError * _Nonnull error) {
|
|
220
|
+
[self failureFor:command resultString:error.localizedDescription];
|
|
221
|
+
}];
|
|
219
222
|
}
|
|
220
223
|
|
|
221
224
|
- (void)purchasedSubscription:(CDVInvokedUrlCommand*)command {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
self.purchasedCommand = command;
|
|
226
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
227
|
+
selector:@selector(reloadContent:)
|
|
228
|
+
name: @"ply_purchasedSubscription"
|
|
229
|
+
object:nil];
|
|
227
230
|
}
|
|
228
231
|
|
|
229
232
|
- (void)allProducts:(CDVInvokedUrlCommand*)command {
|
|
230
|
-
|
|
231
|
-
|
|
233
|
+
[Purchasely allProductsWithSuccess:^(NSArray<PLYProduct *> * _Nonnull products) {
|
|
234
|
+
NSMutableArray *productsArray = [NSMutableArray array];
|
|
232
235
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
for (PLYProduct *product in products) {
|
|
237
|
+
if (product != nil) {
|
|
238
|
+
[productsArray addObject: product.asDictionary];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
238
241
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
[self successFor:command resultArray:productsArray];
|
|
243
|
+
} failure:^(NSError * _Nullable error) {
|
|
244
|
+
[self failureFor:command resultString:error.localizedDescription];
|
|
245
|
+
}];
|
|
243
246
|
}
|
|
244
247
|
|
|
245
248
|
- (void)productWithIdentifier:(CDVInvokedUrlCommand*)command {
|
|
246
|
-
|
|
249
|
+
NSString *productVendorId = [command argumentAtIndex:0];
|
|
247
250
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
[Purchasely productWith:productVendorId
|
|
252
|
+
success:^(PLYProduct * _Nonnull product) {
|
|
253
|
+
[self successFor:command resultDict:product.asDictionary];
|
|
254
|
+
}
|
|
255
|
+
failure:^(NSError * _Nullable error) {
|
|
256
|
+
[self failureFor:command resultString:error.localizedDescription];
|
|
257
|
+
}];
|
|
255
258
|
}
|
|
256
259
|
|
|
257
260
|
- (void)planWithIdentifier:(CDVInvokedUrlCommand*)command {
|
|
258
|
-
|
|
261
|
+
NSString *planVendorId = [command argumentAtIndex:0];
|
|
259
262
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
[Purchasely planWith:planVendorId
|
|
264
|
+
success:^(PLYPlan * _Nonnull plan) {
|
|
265
|
+
[self successFor:command resultDict:plan.asDictionary];
|
|
266
|
+
}
|
|
267
|
+
failure:^(NSError * _Nullable error) {
|
|
268
|
+
[self failureFor:command resultString:error.localizedDescription];
|
|
269
|
+
}];
|
|
267
270
|
}
|
|
268
271
|
|
|
269
272
|
- (void)userSubscriptions:(CDVInvokedUrlCommand*)command {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
273
|
+
[Purchasely userSubscriptionsWithSuccess:^(NSArray<PLYSubscription *> * _Nullable subscriptions) {
|
|
274
|
+
NSMutableArray *result = [NSMutableArray new];
|
|
275
|
+
for (PLYSubscription *subscription in subscriptions) {
|
|
276
|
+
[result addObject:subscription.asDictionary];
|
|
277
|
+
}
|
|
278
|
+
[self successFor:command resultArray:result];
|
|
279
|
+
}
|
|
280
|
+
failure:^(NSError * _Nonnull error) {
|
|
281
|
+
[self failureFor:command resultString:error.localizedDescription];
|
|
282
|
+
}];
|
|
280
283
|
}
|
|
281
284
|
|
|
282
285
|
- (void)addEventsListener:(CDVInvokedUrlCommand*)command {
|
|
283
|
-
|
|
284
|
-
|
|
286
|
+
[Purchasely setEventDelegate:self];
|
|
287
|
+
self.eventCommand = command;
|
|
285
288
|
}
|
|
286
289
|
|
|
287
290
|
- (void)removeEventsListener:(CDVInvokedUrlCommand*)command {
|
|
288
|
-
|
|
289
|
-
|
|
291
|
+
[Purchasely setEventDelegate:nil];
|
|
292
|
+
self.eventCommand = nil;
|
|
290
293
|
}
|
|
291
294
|
|
|
292
295
|
- (void)handle:(CDVInvokedUrlCommand*)command {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
296
|
+
NSString *deeplinkString = [command argumentAtIndex:0];
|
|
297
|
+
NSURL *deeplink = [NSURL URLWithString:deeplinkString];
|
|
298
|
+
|
|
299
|
+
if (deeplink != nil) {
|
|
300
|
+
BOOL result = [Purchasely handleWithDeeplink:deeplink];
|
|
301
|
+
[self successFor:command resultBool:result];
|
|
302
|
+
} else {
|
|
303
|
+
[self successFor:command resultBool:NO];
|
|
304
|
+
}
|
|
302
305
|
}
|
|
303
306
|
|
|
304
307
|
- (void)close:(CDVInvokedUrlCommand*)command {
|
|
305
308
|
}
|
|
306
309
|
|
|
307
310
|
- (void)setLanguage:(CDVInvokedUrlCommand*)command {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
+
NSString *language = [command argumentAtIndex:0];
|
|
312
|
+
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:language];
|
|
313
|
+
[Purchasely setLanguageFrom:locale];
|
|
311
314
|
}
|
|
312
315
|
|
|
313
316
|
// Helpers
|
|
314
317
|
|
|
315
318
|
- (NSDictionary<NSString *, NSObject *> *) resultDictionaryForPresentationController:(PLYProductViewControllerResult)result plan:(PLYPlan * _Nullable)plan {
|
|
316
|
-
|
|
317
|
-
|
|
319
|
+
NSMutableDictionary<NSString *, NSObject *> *productViewResult = [NSMutableDictionary new];
|
|
320
|
+
int resultString;
|
|
318
321
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
322
|
+
switch (result) {
|
|
323
|
+
case PLYProductViewControllerResultPurchased:
|
|
324
|
+
resultString = PLYProductViewControllerResultPurchased;
|
|
325
|
+
break;
|
|
326
|
+
case PLYProductViewControllerResultRestored:
|
|
327
|
+
resultString = PLYProductViewControllerResultRestored;
|
|
328
|
+
break;
|
|
329
|
+
case PLYProductViewControllerResultCancelled:
|
|
330
|
+
resultString = PLYProductViewControllerResultCancelled;
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
330
333
|
|
|
331
|
-
|
|
334
|
+
[productViewResult setObject:[NSNumber numberWithInt:resultString] forKey:@"result"];
|
|
332
335
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
336
|
+
if (plan != nil) {
|
|
337
|
+
[productViewResult setObject:[plan asDictionary] forKey:@"plan"];
|
|
338
|
+
}
|
|
339
|
+
return productViewResult;
|
|
337
340
|
}
|
|
338
341
|
|
|
339
342
|
- (NSDictionary<NSString *, NSObject *> *) resultDictionaryForActionInterceptor:(PLYPresentationAction) action
|
|
@@ -380,6 +383,13 @@
|
|
|
380
383
|
if (infos.placementId != nil) {
|
|
381
384
|
[infosResult setObject:infos.placementId forKey:@"placementId"];
|
|
382
385
|
}
|
|
386
|
+
if (infos.abTestId != nil) {
|
|
387
|
+
[infosResult setObject:infos.abTestId forKey:@"abTestId"];
|
|
388
|
+
}
|
|
389
|
+
if (infos.abTestVariantId != nil) {
|
|
390
|
+
[infosResult setObject:infos.abTestVariantId forKey:@"abTestVariantId"];
|
|
391
|
+
}
|
|
392
|
+
|
|
383
393
|
[actionInterceptorResult setObject:infosResult forKey:@"info"];
|
|
384
394
|
}
|
|
385
395
|
if (params != nil) {
|
|
@@ -433,43 +443,43 @@
|
|
|
433
443
|
}
|
|
434
444
|
|
|
435
445
|
- (void)successFor:(CDVInvokedUrlCommand *)command {
|
|
436
|
-
|
|
437
|
-
|
|
446
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
447
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
438
448
|
}
|
|
439
449
|
|
|
440
450
|
- (void)successFor:(CDVInvokedUrlCommand *)command resultBool:(BOOL)resultBool {
|
|
441
|
-
|
|
442
|
-
|
|
451
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:resultBool];
|
|
452
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
443
453
|
}
|
|
444
454
|
|
|
445
455
|
- (void)successFor:(CDVInvokedUrlCommand *)command resultString:(NSString *)resultString {
|
|
446
|
-
|
|
447
|
-
|
|
456
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:resultString];
|
|
457
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
448
458
|
}
|
|
449
459
|
|
|
450
460
|
- (void)failureFor:(CDVInvokedUrlCommand *)command resultString:(NSString *)resultString {
|
|
451
|
-
|
|
452
|
-
|
|
461
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:resultString];
|
|
462
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
453
463
|
}
|
|
454
464
|
|
|
455
465
|
- (void)successFor:(CDVInvokedUrlCommand *)command resultArray:(NSArray *)resultArray {
|
|
456
|
-
|
|
457
|
-
|
|
466
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:resultArray];
|
|
467
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
458
468
|
}
|
|
459
469
|
|
|
460
470
|
- (void)failureFor:(CDVInvokedUrlCommand *)command resultArray:(NSArray *)resultArray {
|
|
461
|
-
|
|
462
|
-
|
|
471
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsArray:resultArray];
|
|
472
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
463
473
|
}
|
|
464
474
|
|
|
465
475
|
- (void)successFor:(CDVInvokedUrlCommand *)command resultDict:(NSDictionary *)resultDict {
|
|
466
|
-
|
|
467
|
-
|
|
476
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultDict];
|
|
477
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
468
478
|
}
|
|
469
479
|
|
|
470
480
|
- (void)failureFor:(CDVInvokedUrlCommand *)command resultDict:(NSDictionary *)resultDict {
|
|
471
|
-
|
|
472
|
-
|
|
481
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:resultDict];
|
|
482
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
473
483
|
}
|
|
474
484
|
|
|
475
485
|
|
package/www/Purchasely.js
CHANGED
|
@@ -3,7 +3,11 @@ var exec = require('cordova/exec');
|
|
|
3
3
|
var defaultError = (e) => { console.log(e); }
|
|
4
4
|
|
|
5
5
|
exports.startWithAPIKey = function (apiKey, stores, userId, logLevel, runningMode, success, error) {
|
|
6
|
-
|
|
6
|
+
var cordovaSdkVersion = cordova.define.moduleMap['cordova/plugin_list'].exports['metadata']['cordova-plugin-purchasely']
|
|
7
|
+
if(!cordovaSdkVersion) {
|
|
8
|
+
cordovaSdkVersion = "2.2.0" //fallback if we cannot find version from metadata
|
|
9
|
+
}
|
|
10
|
+
exec(success, error, 'Purchasely', 'startWithAPIKey', [apiKey, stores, userId, logLevel, runningMode, cordovaSdkVersion]);
|
|
7
11
|
};
|
|
8
12
|
|
|
9
13
|
exports.addEventsListener = function (success, error) {
|
|
@@ -133,7 +137,12 @@ exports.Attribute = {
|
|
|
133
137
|
AMPLITUDE_SESSION_ID: 0,
|
|
134
138
|
FIREBASE_APP_INSTANCE_ID: 1,
|
|
135
139
|
AIRSHIP_CHANNEL_ID: 2,
|
|
136
|
-
|
|
140
|
+
BATCH_INSTALLATION_ID: 3,
|
|
141
|
+
ADJUST_ID: 4,
|
|
142
|
+
APPSFLYER_ID: 5,
|
|
143
|
+
ONESIGNAL_PLAYER_ID: 6,
|
|
144
|
+
MIXPANEL_DISTINCT_ID: 7,
|
|
145
|
+
CLEVER_TAP_ID: 8
|
|
137
146
|
}
|
|
138
147
|
|
|
139
148
|
exports.PurchaseResult = {
|