@purchasely/cordova-plugin-purchasely 6.0.0 → 6.0.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/Package.swift +77 -0
- package/package.json +11 -2
- package/plugin.xml +4 -4
- package/src/ios/CDVPurchasely.m +22 -4
- package/www/Purchasely.js +1 -1
- package/__tests__/Purchasely.test.js +0 -1826
- package/example/IOS_8_1_1_TEST_MATRIX.md +0 -25
- package/example/android.sh +0 -10
- package/example/config.xml +0 -27
- package/example/e2e/README.md +0 -44
- package/example/e2e/helpers/driver.js +0 -187
- package/example/e2e/package.json +0 -19
- package/example/e2e/specs/bridge.e2e.js +0 -154
- package/example/e2e/specs/dismiss.e2e.js +0 -57
- package/example/e2e/tools/ci_run_e2e.sh +0 -63
- package/example/e2e/tools/ci_run_e2e_ios.sh +0 -56
- package/example/e2e/wdio.android.conf.js +0 -24
- package/example/e2e/wdio.ios.conf.js +0 -44
- package/example/e2e/wdio.shared.conf.js +0 -28
- package/example/ios.sh +0 -17
- package/example/package-lock.json +0 -859
- package/example/package.json +0 -37
- package/example/www/css/index.css +0 -110
- package/example/www/img/logo.png +0 -0
- package/example/www/index.html +0 -78
- package/example/www/js/index.js +0 -453
- package/purchasely.iml +0 -11
package/example/package.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "io.purchasely.sample",
|
|
3
|
-
"displayName": "HelloCordova",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"description": "A sample Apache Cordova application that responds to the deviceready event.",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [
|
|
11
|
-
"ecosystem:cordova"
|
|
12
|
-
],
|
|
13
|
-
"author": "Apache Cordova Team",
|
|
14
|
-
"license": "Apache-2.0",
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@purchasely/cordova-plugin-purchasely": "file:..",
|
|
17
|
-
"@purchasely/cordova-plugin-purchasely-google": "file:../../purchasely-google",
|
|
18
|
-
"cordova-android": "^15.0.0",
|
|
19
|
-
"cordova-ios": "8.1.1",
|
|
20
|
-
"cordova-plugin-purchasely": "file:..",
|
|
21
|
-
"cordova-plugin-purchasely-google": "file:../../purchasely-google"
|
|
22
|
-
},
|
|
23
|
-
"overrides": {
|
|
24
|
-
"@xmldom/xmldom": "^0.9.8",
|
|
25
|
-
"plist": "^3.1.1",
|
|
26
|
-
"uuid": "^11.1.1"
|
|
27
|
-
},
|
|
28
|
-
"cordova": {
|
|
29
|
-
"plugins": {
|
|
30
|
-
"@purchasely/cordova-plugin-purchasely-google": {}
|
|
31
|
-
},
|
|
32
|
-
"platforms": [
|
|
33
|
-
"ios",
|
|
34
|
-
"android"
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
* {
|
|
20
|
-
-webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
body {
|
|
24
|
-
-webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
|
|
25
|
-
-webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */
|
|
26
|
-
-webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
|
|
27
|
-
background-color:#E4E4E4;
|
|
28
|
-
background-image:linear-gradient(to bottom, #A7A7A7 0%, #E4E4E4 51%);
|
|
29
|
-
font-family: system-ui, -apple-system, -apple-system-font, 'Segoe UI', 'Roboto', sans-serif;
|
|
30
|
-
font-size:12px;
|
|
31
|
-
height:100vh;
|
|
32
|
-
margin:0px;
|
|
33
|
-
padding:0px;
|
|
34
|
-
/* Padding to avoid the "unsafe" areas behind notches in the screen */
|
|
35
|
-
padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
|
|
36
|
-
text-transform:uppercase;
|
|
37
|
-
width:100%;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/* Portrait layout (default) */
|
|
41
|
-
.app {
|
|
42
|
-
background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */
|
|
43
|
-
position:absolute; /* position in the center of the screen */
|
|
44
|
-
left:50%;
|
|
45
|
-
top:50%;
|
|
46
|
-
height:50px; /* text area height */
|
|
47
|
-
width:225px; /* text area width */
|
|
48
|
-
text-align:center;
|
|
49
|
-
padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */
|
|
50
|
-
margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */
|
|
51
|
-
/* offset horizontal: half of text area width */
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/* Landscape layout (with min-width) */
|
|
55
|
-
@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
|
|
56
|
-
.app {
|
|
57
|
-
background-position:left center;
|
|
58
|
-
padding:75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */
|
|
59
|
-
margin:-90px 0px 0px -198px; /* offset vertical: half of image height */
|
|
60
|
-
/* offset horizontal: half of image width and text area width */
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
h1 {
|
|
65
|
-
font-size:24px;
|
|
66
|
-
font-weight:normal;
|
|
67
|
-
margin:0px;
|
|
68
|
-
overflow:visible;
|
|
69
|
-
padding:0px;
|
|
70
|
-
text-align:center;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.event {
|
|
74
|
-
border-radius:4px;
|
|
75
|
-
color:#FFFFFF;
|
|
76
|
-
font-size:12px;
|
|
77
|
-
margin:0px 30px;
|
|
78
|
-
padding:2px 0px;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.event.listening {
|
|
82
|
-
background-color:#333333;
|
|
83
|
-
display:block;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.event.received {
|
|
87
|
-
background-color:#4B946A;
|
|
88
|
-
display:none;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
#deviceready.ready .event.listening { display: none; }
|
|
92
|
-
#deviceready.ready .event.received { display: block; }
|
|
93
|
-
|
|
94
|
-
@keyframes fade {
|
|
95
|
-
from { opacity: 1.0; }
|
|
96
|
-
50% { opacity: 0.4; }
|
|
97
|
-
to { opacity: 1.0; }
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.blink {
|
|
101
|
-
animation:fade 3000ms infinite;
|
|
102
|
-
-webkit-animation:fade 3000ms infinite;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
@media screen and (prefers-color-scheme: dark) {
|
|
107
|
-
body {
|
|
108
|
-
background-image:linear-gradient(to bottom, #585858 0%, #1B1B1B 51%);
|
|
109
|
-
}
|
|
110
|
-
}
|
package/example/www/img/logo.png
DELETED
|
Binary file
|
package/example/www/index.html
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<!--
|
|
3
|
-
Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
-
or more contributor license agreements. See the NOTICE file
|
|
5
|
-
distributed with this work for additional information
|
|
6
|
-
regarding copyright ownership. The ASF licenses this file
|
|
7
|
-
to you under the Apache License, Version 2.0 (the
|
|
8
|
-
"License"); you may not use this file except in compliance
|
|
9
|
-
with the License. You may obtain a copy of the License at
|
|
10
|
-
|
|
11
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
Unless required by applicable law or agreed to in writing,
|
|
14
|
-
software distributed under the License is distributed on an
|
|
15
|
-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
KIND, either express or implied. See the License for the
|
|
17
|
-
specific language governing permissions and limitations
|
|
18
|
-
under the License.
|
|
19
|
-
-->
|
|
20
|
-
<html>
|
|
21
|
-
<head>
|
|
22
|
-
<meta charset="utf-8">
|
|
23
|
-
<!--
|
|
24
|
-
Customize this policy to fit your own app's needs. For more guidance, see:
|
|
25
|
-
https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
|
|
26
|
-
Some notes:
|
|
27
|
-
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
|
|
28
|
-
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
|
|
29
|
-
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
|
|
30
|
-
* Enable inline JS: add 'unsafe-inline' to default-src
|
|
31
|
-
-->
|
|
32
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
|
|
33
|
-
<meta name="format-detection" content="telephone=no">
|
|
34
|
-
<meta name="msapplication-tap-highlight" content="no">
|
|
35
|
-
<meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
|
|
36
|
-
<meta name="color-scheme" content="light dark">
|
|
37
|
-
<link rel="stylesheet" href="css/index.css">
|
|
38
|
-
<title>Hello World</title>
|
|
39
|
-
</head>
|
|
40
|
-
<body>
|
|
41
|
-
<div class="app">
|
|
42
|
-
<h1>Apache Cordova</h1>
|
|
43
|
-
<div id="deviceready" class="blink">
|
|
44
|
-
<p class="event listening">Connecting to Device</p>
|
|
45
|
-
<p class="event received">Device is Ready</p>
|
|
46
|
-
</div>
|
|
47
|
-
<div style="margin-top: 20px;">
|
|
48
|
-
<button id="openPresentation">Open Presentation</button>
|
|
49
|
-
</div>
|
|
50
|
-
<div style="margin-top: 20px;">
|
|
51
|
-
<button id="fetchPresentation">Fetch Presentation</button>
|
|
52
|
-
</div>
|
|
53
|
-
<div style="margin-top: 20px;">
|
|
54
|
-
<button id="processToPayment">Continue payment</button>
|
|
55
|
-
</div>
|
|
56
|
-
<div style="margin-top: 20px;">
|
|
57
|
-
<button id="backPresentation">Back presentation</button>
|
|
58
|
-
</div>
|
|
59
|
-
<div style="margin-top: 20px;">
|
|
60
|
-
<button id="closePresentation">Close presentation</button>
|
|
61
|
-
</div>
|
|
62
|
-
<div style="margin-top: 20px;">
|
|
63
|
-
<button id="purchaseWithPlanVendorId">Purchase</button>
|
|
64
|
-
</div>
|
|
65
|
-
<div style="margin-top: 20px;">
|
|
66
|
-
<button id="restore">Restore</button>
|
|
67
|
-
</div>
|
|
68
|
-
<div style="margin-top: 20px;">
|
|
69
|
-
<button id="silentRestore">Silent restore</button>
|
|
70
|
-
</div>
|
|
71
|
-
<div style="margin-top: 20px;">
|
|
72
|
-
<button id="openDeeplink">Deeplink</button>
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
<script src="cordova.js"></script>
|
|
76
|
-
<script src="js/index.js"></script>
|
|
77
|
-
</body>
|
|
78
|
-
</html>
|
package/example/www/js/index.js
DELETED
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
function safeStringify(obj, space = 2) {
|
|
21
|
-
const seen = new WeakSet();
|
|
22
|
-
return JSON.stringify(obj, (key, value) => {
|
|
23
|
-
if (typeof value === 'object' && value !== null) {
|
|
24
|
-
if (seen.has(value)) {
|
|
25
|
-
return '[Circular Reference]';
|
|
26
|
-
}
|
|
27
|
-
seen.add(value);
|
|
28
|
-
}
|
|
29
|
-
return value;
|
|
30
|
-
}, space);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Wait for the deviceready event before using any of Cordova's device APIs.
|
|
34
|
-
// See https://cordova.apache.org/docs/en/latest/cordova/events/events.html#deviceready
|
|
35
|
-
document.addEventListener('deviceready', onDeviceReady, false);
|
|
36
|
-
|
|
37
|
-
function onDeviceReady() {
|
|
38
|
-
// Cordova is now initialized. Have fun!
|
|
39
|
-
|
|
40
|
-
console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
|
|
41
|
-
document.getElementById('deviceready').classList.add('ready');
|
|
42
|
-
|
|
43
|
-
Purchasely.start(
|
|
44
|
-
{
|
|
45
|
-
apiKey: 'fcb39be4-2ba4-4db7-bde3-2a5a1e20745d',
|
|
46
|
-
stores: [Purchasely.Store.google],
|
|
47
|
-
storeKit1: false,
|
|
48
|
-
logLevel: Purchasely.LogLevel.DEBUG,
|
|
49
|
-
runningMode: Purchasely.RunningMode.full
|
|
50
|
-
},
|
|
51
|
-
(isConfigured) => {
|
|
52
|
-
if(isConfigured) onPurchaselySdkReady();
|
|
53
|
-
},
|
|
54
|
-
(error) => {
|
|
55
|
-
console.log(error);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
Purchasely.setDebugMode(true);
|
|
59
|
-
|
|
60
|
-
Purchasely.setLanguage('en');
|
|
61
|
-
|
|
62
|
-
document.getElementById("openPresentation").addEventListener("click", openPresentation);
|
|
63
|
-
document.getElementById("fetchPresentation").addEventListener("click", fetchPresentation);
|
|
64
|
-
document.getElementById("backPresentation").addEventListener("click", backPresentation);
|
|
65
|
-
document.getElementById("closePresentation").addEventListener("click", closePresentation);
|
|
66
|
-
document.getElementById("purchaseWithPlanVendorId").addEventListener("click", purchaseWithPlanVendorId);
|
|
67
|
-
document.getElementById("restore").addEventListener("click", restore);
|
|
68
|
-
document.getElementById("silentRestore").addEventListener("click", silentRestore);
|
|
69
|
-
document.getElementById("processToPayment").addEventListener("click", processToPayment);
|
|
70
|
-
document.getElementById("openDeeplink").addEventListener("click", openDeeplink);
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function onPurchaselySdkReady() {
|
|
75
|
-
Purchasely.allProducts( products => {
|
|
76
|
-
console.log("Products " + products.length);
|
|
77
|
-
console.log("First product name: " + products[0].name);
|
|
78
|
-
}, (error) => {
|
|
79
|
-
console.log(error);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
Purchasely.getAnonymousUserId(id => { console.log("Purchasely anonymous Id:" + id) });
|
|
83
|
-
|
|
84
|
-
Purchasely.addEventsListener((event) => {
|
|
85
|
-
console.log("Event Name " + event.name);
|
|
86
|
-
console.log(safeStringify(event.properties));
|
|
87
|
-
console.log(safeStringify(event));
|
|
88
|
-
}, (error) => {
|
|
89
|
-
console.log(error);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
Purchasely.addUserAttributeListener((attribute) => {
|
|
93
|
-
if (attribute.action == Purchasely.UserAttributeAction.ADD) {
|
|
94
|
-
console.log("ADD Attribute: " + attribute.key)
|
|
95
|
-
console.log("ADD Attribute: " + attribute.value)
|
|
96
|
-
console.log("ADD Attribute: " + attribute.source)
|
|
97
|
-
console.log("ADD Attribute: " + attribute.type)
|
|
98
|
-
} else if (attribute.action == Purchasely.UserAttributeAction.REMOVE) {
|
|
99
|
-
console.log("REMOVE Attribute: " + attribute.key)
|
|
100
|
-
console.log("REMOVE Attribute: " + attribute.source)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
}, (error) => {
|
|
104
|
-
console.log("Error: " + error)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
Purchasely.purchasedSubscription(() => {
|
|
108
|
-
console.log("Purchased performed, reload content to unlock.");
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
Purchasely.userLogin('test_cordova', refresh => {
|
|
112
|
-
console.log("User logged, refresh needed ? " + refresh);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
Purchasely.userLogout();
|
|
116
|
-
|
|
117
|
-
Purchasely.setLogLevel(Purchasely.LogLevel.DEBUG);
|
|
118
|
-
|
|
119
|
-
Purchasely.setAttribute(Purchasely.Attribute.FIREBASE_APP_INSTANCE_ID, "firebase_instance_id");
|
|
120
|
-
Purchasely.setAttribute(Purchasely.Attribute.AIRSHIP_CHANNEL_ID, "airship_channel_id");
|
|
121
|
-
Purchasely.setAttribute(Purchasely.Attribute.AIRSHIP_USER_ID, "airship_user_id");
|
|
122
|
-
Purchasely.setAttribute(Purchasely.Attribute.BATCH_INSTALLATION_ID, "batch_installation_id");
|
|
123
|
-
Purchasely.setAttribute(Purchasely.Attribute.ADJUST_ID, "adjust_id");
|
|
124
|
-
Purchasely.setAttribute(Purchasely.Attribute.APPSFLYER_ID, "appsflyer_id");
|
|
125
|
-
Purchasely.setAttribute(Purchasely.Attribute.MIXPANEL_DISTINCT_ID, "mixpanel_distinct_id");
|
|
126
|
-
Purchasely.setAttribute(Purchasely.Attribute.CLEVER_TAP_ID, "clever_tap_id");
|
|
127
|
-
Purchasely.setAttribute(Purchasely.Attribute.SENDINBLUE_USER_EMAIL, "sendinblue_user_email");
|
|
128
|
-
Purchasely.setAttribute(Purchasely.Attribute.ITERABLE_USER_EMAIL, "iterable_user_email");
|
|
129
|
-
Purchasely.setAttribute(Purchasely.Attribute.ITERABLE_USER_ID, "iterable_user_id");
|
|
130
|
-
Purchasely.setAttribute(Purchasely.Attribute.AT_INTERNET_ID_CLIENT, "at_internet_id_client");
|
|
131
|
-
Purchasely.setAttribute(Purchasely.Attribute.MPARTICLE_USER_ID, "mparticle_user_id");
|
|
132
|
-
Purchasely.setAttribute(Purchasely.Attribute.CUSTOMERIO_USER_ID, "customerio_user_id");
|
|
133
|
-
Purchasely.setAttribute(Purchasely.Attribute.CUSTOMERIO_USER_EMAIL, "customerio_user_email");
|
|
134
|
-
Purchasely.setAttribute(Purchasely.Attribute.BRANCH_USER_DEVELOPER_IDENTITY, "branch_user_developer_identity");
|
|
135
|
-
Purchasely.setAttribute(Purchasely.Attribute.AMPLITUDE_USER_ID, "amplitude_user_id");
|
|
136
|
-
Purchasely.setAttribute(Purchasely.Attribute.AMPLITUDE_DEVICE_ID, "amplitude_device_id");
|
|
137
|
-
Purchasely.setAttribute(Purchasely.Attribute.MOENGAGE_UNIQUE_ID, "moengage_unique_id");
|
|
138
|
-
Purchasely.setAttribute(Purchasely.Attribute.ONESIGNAL_EXTERNAL_ID, "onesignal_external_id");
|
|
139
|
-
Purchasely.setAttribute(Purchasely.Attribute.BATCH_CUSTOM_USER_ID, "batch_custom_user_id");
|
|
140
|
-
Purchasely.setAttribute(Purchasely.Attribute.BATCH_INSTALLATION_ID, "testBatch1");
|
|
141
|
-
|
|
142
|
-
Purchasely.allowDeeplink(true);
|
|
143
|
-
|
|
144
|
-
Purchasely.planWithIdentifier('PURCHASELY_PLUS_MONTHLY', (plan) => {
|
|
145
|
-
console.log(' ==> Plan');
|
|
146
|
-
console.log(plan.vendorId);
|
|
147
|
-
console.log(plan.productId);
|
|
148
|
-
console.log(plan.name);
|
|
149
|
-
console.log(plan.price);
|
|
150
|
-
console.log(plan.amount);
|
|
151
|
-
console.log(plan.period);
|
|
152
|
-
console.log(plan.hasIntroductoryPrice);
|
|
153
|
-
console.log(plan.introPrice);
|
|
154
|
-
console.log(plan.introAmount);
|
|
155
|
-
console.log(plan.introDuration);
|
|
156
|
-
}, (error) => {
|
|
157
|
-
console.log(error);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
Purchasely.setDefaultPresentationDismissHandler(callback => {
|
|
161
|
-
console.log('[setDefaultPresentationDismissHandler] onDismissed — purchaseResult=' + callback.purchaseResult + ' closeReason=' + callback.closeReason + ' — outcome: ' + safeStringify(callback));
|
|
162
|
-
if(callback.result == Purchasely.PurchaseResult.CANCELLED) {
|
|
163
|
-
console.log("User cancelled purchase - close reason " + callback.closeReason);
|
|
164
|
-
} else if (callback.plan) {
|
|
165
|
-
console.log("User purchased " + callback.plan.vendorId);
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
(error) => {
|
|
169
|
-
console.log("[setDefaultPresentationDismissHandler] error: " + error);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
Purchasely.setUserAttributeWithString("key_string", "value_string", Purchasely.DataProcessingLegalBasis.essential);
|
|
173
|
-
Purchasely.setUserAttributeWithBoolean("key_boolean", true, Purchasely.DataProcessingLegalBasis.essential);
|
|
174
|
-
Purchasely.setUserAttributeWithInt("key_int", 7, Purchasely.DataProcessingLegalBasis.essential);
|
|
175
|
-
Purchasely.setUserAttributeWithDouble("key_double", 4.5, Purchasely.DataProcessingLegalBasis.essential);
|
|
176
|
-
Purchasely.setUserAttributeWithDate("key_date", new Date().toISOString(), Purchasely.DataProcessingLegalBasis.essential);
|
|
177
|
-
|
|
178
|
-
Purchasely.clearUserAttributes();
|
|
179
|
-
|
|
180
|
-
Purchasely.setUserAttributeWithString("key_string", "value_string");
|
|
181
|
-
Purchasely.setUserAttributeWithBoolean("key_boolean", true);
|
|
182
|
-
Purchasely.setUserAttributeWithInt("key_int", 7);
|
|
183
|
-
Purchasely.setUserAttributeWithDouble("key_double", 4.5);
|
|
184
|
-
Purchasely.setUserAttributeWithDate("key_date", new Date().toISOString());
|
|
185
|
-
|
|
186
|
-
Purchasely.setUserAttributeWithStringArray("key_string_array", ["value1", "value2"]);
|
|
187
|
-
Purchasely.setUserAttributeWithIntArray("key_int_array", [1, 2, 3]);
|
|
188
|
-
Purchasely.setUserAttributeWithDoubleArray("key_double_array", [1.1, 2.2, 3.3]);
|
|
189
|
-
Purchasely.setUserAttributeWithBooleanArray("key_boolean_array", [true, false, true]);
|
|
190
|
-
|
|
191
|
-
Purchasely.revokeDataProcessingConsent(["CAMPAIGNS"])
|
|
192
|
-
|
|
193
|
-
Purchasely.userAttribute("key_string", value => {
|
|
194
|
-
console.log("User attribute string: " + value);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
Purchasely.userAttribute("key_boolean", value => {
|
|
198
|
-
console.log("User attribute boolean: " + value);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
Purchasely.userAttribute("key_int", value => {
|
|
202
|
-
console.log("User attribute int: " + value);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
Purchasely.userAttribute("key_double", value => {
|
|
206
|
-
console.log("User attribute double: " + value);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
Purchasely.userAttribute("key_string_array", value => {
|
|
210
|
-
console.log("User attribute string array: " + value);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
Purchasely.userAttribute("key_int_array", value => {
|
|
214
|
-
console.log("User attribute int array: " + value);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
Purchasely.userAttribute("key_double_array", value => {
|
|
218
|
-
console.log("User attribute double array: " + value);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
Purchasely.userAttribute("key_boolean_array", value => {
|
|
222
|
-
console.log("User attribute boolean array: " + value);
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
Purchasely.userAttribute("key_date", value => {
|
|
226
|
-
console.log("User attribute date " + value);
|
|
227
|
-
|
|
228
|
-
Purchasely.clearUserAttribute("key_string");
|
|
229
|
-
Purchasely.userAttribute("key_string",{}, error => {
|
|
230
|
-
console.log("User attribute string cleared ? " + error);
|
|
231
|
-
|
|
232
|
-
Purchasely.clearUserAttributes();
|
|
233
|
-
Purchasely.userAttribute("key_double", {}, error => {
|
|
234
|
-
console.log("User attribute double empty? " + error);
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
Purchasely.removeUserAttributeListener();
|
|
240
|
-
|
|
241
|
-
// Purchasely 6.0: per-action interceptor. Register a handler per action kind; each
|
|
242
|
-
// handler receives (info, parameters) and returns a Purchasely.InterceptResult telling
|
|
243
|
-
// the SDK how it was handled (notHandled = let the SDK proceed, success = app handled it).
|
|
244
|
-
Purchasely.removeAllActionInterceptors();
|
|
245
|
-
|
|
246
|
-
// NOTE: `info` and `parameters` can be null depending on the action and the
|
|
247
|
-
// platform (e.g. on iOS the `close` action carries no parameters). Always log
|
|
248
|
-
// them with safeStringify (null-safe) rather than reading fields directly, or
|
|
249
|
-
// a thrown handler is reported to the SDK as `failed` and the action (e.g.
|
|
250
|
-
// close) will NOT be performed.
|
|
251
|
-
Purchasely.interceptAction(Purchasely.PresentationAction.navigate, (info, parameters) => {
|
|
252
|
-
console.log('[interceptAction] navigate — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
|
|
253
|
-
return Purchasely.InterceptResult.notHandled;
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
Purchasely.interceptAction(Purchasely.PresentationAction.close, (info, parameters) => {
|
|
257
|
-
console.log('[interceptAction] close — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
|
|
258
|
-
return Purchasely.InterceptResult.notHandled;
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
Purchasely.interceptAction(Purchasely.PresentationAction.closeAll, (info, parameters) => {
|
|
262
|
-
console.log('[interceptAction] close_all — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
|
|
263
|
-
return Purchasely.InterceptResult.notHandled;
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
Purchasely.interceptAction(Purchasely.PresentationAction.login, (info, parameters) => {
|
|
267
|
-
console.log('[interceptAction] login — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
|
|
268
|
-
// Present your own screen for the user to log in, then report success so the paywall refreshes.
|
|
269
|
-
Purchasely.closePresentation();
|
|
270
|
-
Purchasely.userLogin('MY_USER_ID');
|
|
271
|
-
return Purchasely.InterceptResult.success;
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
Purchasely.interceptAction(Purchasely.PresentationAction.openPresentation, (info, parameters) => {
|
|
275
|
-
console.log('[interceptAction] open_presentation — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
|
|
276
|
-
return Purchasely.InterceptResult.notHandled;
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
Purchasely.interceptAction(Purchasely.PresentationAction.openPlacement, (info, parameters) => {
|
|
280
|
-
console.log('[interceptAction] open_placement — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
|
|
281
|
-
return Purchasely.InterceptResult.notHandled;
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
Purchasely.interceptAction(Purchasely.PresentationAction.purchase, (info, parameters) => {
|
|
285
|
-
console.log('[interceptAction] purchase — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
|
|
286
|
-
// Let the SDK proceed with the purchase.
|
|
287
|
-
return Purchasely.InterceptResult.notHandled;
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
Purchasely.interceptAction(Purchasely.PresentationAction.webCheckout, (info, parameters) => {
|
|
291
|
-
console.log('[interceptAction] web_checkout — info: ' + safeStringify(info) + ' — parameters: ' + safeStringify(parameters));
|
|
292
|
-
return Purchasely.InterceptResult.notHandled;
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
Purchasely.clearBuiltInAttributes();
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
// Purchasely 6.0: `back()`/`close()` live on the request, not as bare top-level calls
|
|
299
|
-
// (backPresentation() was removed). The example keeps a reference to the last request
|
|
300
|
-
// it built/displayed so the "Back presentation" button below has something to drive.
|
|
301
|
-
var currentPresentationRequest = null;
|
|
302
|
-
|
|
303
|
-
function openPresentation() {
|
|
304
|
-
// Purchasely 6.0: the v6 builder — pick a source (.placement/.screen/.defaultSource),
|
|
305
|
-
// chain lifecycle callbacks, .build(), then .display(transition?). display() resolves
|
|
306
|
-
// at dismiss with a 5-field outcome: { presentation, purchaseResult, plan, closeReason, error }.
|
|
307
|
-
currentPresentationRequest = Purchasely.presentation
|
|
308
|
-
.placement('ONBOARDING')
|
|
309
|
-
.onPresented((presentation, error) => {
|
|
310
|
-
console.log('[openPresentation] onPresented — ' + (presentation ? presentation.screenId : '') + (error ? ' error=' + error : ''));
|
|
311
|
-
})
|
|
312
|
-
.onCloseRequested(() => {
|
|
313
|
-
console.log('[openPresentation] onCloseRequested');
|
|
314
|
-
})
|
|
315
|
-
.build();
|
|
316
|
-
|
|
317
|
-
currentPresentationRequest
|
|
318
|
-
.display(Purchasely.TransitionType.fullScreen) //display mode (string) — or a transition object, see below
|
|
319
|
-
.then((outcome) => {
|
|
320
|
-
console.log('[openPresentation] onDismissed — purchaseResult=' + outcome.purchaseResult + ' — outcome: ' + safeStringify(outcome));
|
|
321
|
-
if (outcome.error) {
|
|
322
|
-
console.log("[openPresentation] error: " + outcome.error);
|
|
323
|
-
} else if (outcome.purchaseResult === 'purchased' || outcome.purchaseResult === 'restored') {
|
|
324
|
-
console.log("User purchased " + (outcome.plan ? outcome.plan.name : ''));
|
|
325
|
-
} else {
|
|
326
|
-
console.log("User cancelled purchased - close reason " + outcome.closeReason);
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
// Purchasely 6.0 also supports:
|
|
331
|
-
// - a rich transition object for drawer/popin sizing (see fetchPresentation below):
|
|
332
|
-
// { type: Purchasely.TransitionType.drawer, dismissible: true,
|
|
333
|
-
// height: { type: Purchasely.DimensionType.percentage, value: 0.8 }, backgroundColor: '#000000' }
|
|
334
|
-
// - the default (audience-targeted) presentation, targeted with .defaultSource() (or its
|
|
335
|
-
// iOS-style alias .default()):
|
|
336
|
-
// Purchasely.presentation.defaultSource().build().display(Purchasely.TransitionType.fullScreen);
|
|
337
|
-
// - stopping campaign/deeplink dismiss outcomes:
|
|
338
|
-
// Purchasely.removeDefaultPresentationDismissHandler();
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function fetchPresentation() {
|
|
342
|
-
// Purchasely 6.0: preload() fetches without displaying; the resolved presentation
|
|
343
|
-
// exposes screenId (the authoritative identifier). Calling display() on the SAME
|
|
344
|
-
// request re-displays exactly what was preloaded.
|
|
345
|
-
const request = Purchasely.presentation.placement('flow_demo').build();
|
|
346
|
-
currentPresentationRequest = request;
|
|
347
|
-
request.preload().then((presentation) => {
|
|
348
|
-
console.log('[fetchPresentation] onFetched — presentation: ' + safeStringify(presentation));
|
|
349
|
-
// Rich transition object: drawer at 80% height, dismissible. (iOS applies the
|
|
350
|
-
// percentage height + dismissible; Android also supports pixel + popin width.)
|
|
351
|
-
request.display({
|
|
352
|
-
type: Purchasely.TransitionType.drawer,
|
|
353
|
-
dismissible: true,
|
|
354
|
-
height: { type: Purchasely.DimensionType.percentage, value: 0.8 }
|
|
355
|
-
}).then((outcome) => {
|
|
356
|
-
console.log('[fetchPresentation → display] onDismissed — purchaseResult=' + outcome.purchaseResult + ' — outcome: ' + safeStringify(outcome));
|
|
357
|
-
if (outcome.error) {
|
|
358
|
-
console.log("[fetchPresentation → display] error: " + outcome.error);
|
|
359
|
-
} else if (outcome.purchaseResult === 'purchased' || outcome.purchaseResult === 'restored') {
|
|
360
|
-
console.log("User purchased " + (outcome.plan ? outcome.plan.name : ''));
|
|
361
|
-
} else {
|
|
362
|
-
console.log("User cancelled purchased - close reason " + outcome.closeReason);
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
}, (error) => {
|
|
366
|
-
console.log("[fetchPresentation] error: " + safeStringify(error));
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
function purchaseWithPlanVendorId() {
|
|
371
|
-
Purchasely.purchaseWithPlanVendorId("PURCHASELY_PLUS_MONTHLY");
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
function processToPayment() {
|
|
375
|
-
// Call this method in observer mode to synchronize purchases with Purchasely
|
|
376
|
-
// Purchasely.synchronize((ok) => console.log("synchronized " + ok), (e) => console.log(e));
|
|
377
|
-
|
|
378
|
-
// Purchasely 6.0: with the per-action interceptor (interceptAction), each handler returns
|
|
379
|
-
// its own Purchasely.InterceptResult, so there is no separate "process action" step.
|
|
380
|
-
// Kept as a no-op for the example's existing button wiring.
|
|
381
|
-
console.log('processToPayment: no-op in v6 — interceptAction handlers report their own result');
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function backPresentation() {
|
|
385
|
-
if (currentPresentationRequest) currentPresentationRequest.back();
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
function closePresentation() {
|
|
389
|
-
Purchasely.closePresentation();
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function restore() {
|
|
393
|
-
Purchasely.restoreAllProducts(
|
|
394
|
-
(plan) => {
|
|
395
|
-
if(plan) console.log("Restore " + plan.vendorId);
|
|
396
|
-
else console.log("Nothing to restore");
|
|
397
|
-
},
|
|
398
|
-
(error) => {
|
|
399
|
-
console.log("Restore failed " + error);
|
|
400
|
-
},
|
|
401
|
-
);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
function silentRestore() {
|
|
405
|
-
Purchasely.silentRestoreAllProducts(
|
|
406
|
-
(plan) => {
|
|
407
|
-
if(plan) console.log("Silent restore " + plan.vendorId);
|
|
408
|
-
else console.log("Nothing to restore");
|
|
409
|
-
},
|
|
410
|
-
(error) => {
|
|
411
|
-
console.log("Silent Restore failed " + error);
|
|
412
|
-
},
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function isEligibleForIntroOffer() {
|
|
417
|
-
console.log("isEligibleForIntroOffer");
|
|
418
|
-
Purchasely.isEligibleForIntroOffer(
|
|
419
|
-
'PURCHASELY_PLUS_YEARLY', // planVendorId
|
|
420
|
-
(isEligible) => {
|
|
421
|
-
console.log("isEligibleForIntroOffer result: " + isEligible);
|
|
422
|
-
},
|
|
423
|
-
(error) => {
|
|
424
|
-
console.log("Error with isEligibleForIntroOffer : " + error);
|
|
425
|
-
}
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
function signPromotionalOffer() {
|
|
430
|
-
console.log("signPromotionalOffer");
|
|
431
|
-
Purchasely.signPromotionalOffer(
|
|
432
|
-
'com.purchasely.plus.yearly', // storeProductId
|
|
433
|
-
'com.purchasely.plus.yearly.winback.test', // storeOfferId
|
|
434
|
-
(signature) => {
|
|
435
|
-
console.log("signPromotionalOffer result: " + signature);
|
|
436
|
-
},
|
|
437
|
-
(error) => {
|
|
438
|
-
console.log("Error with signPromotionalOffer : " + error);
|
|
439
|
-
}
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function openDeeplink() {
|
|
444
|
-
Purchasely.handleDeeplink(
|
|
445
|
-
"purchasely://ply/presentations/CAROUSEL",
|
|
446
|
-
isHandled => {
|
|
447
|
-
console.log("Deeplink is handled ? " + isHandled)
|
|
448
|
-
},
|
|
449
|
-
(error) => {
|
|
450
|
-
console.log(error)
|
|
451
|
-
},
|
|
452
|
-
);
|
|
453
|
-
}
|