-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
93 lines (76 loc) · 2.41 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE HTML>
<html>
<head>
<meta name="description" content="flight wallet - Pay Bitcoin securely">
<script>
var serviceAPI = 'http://explorer.flightwallet.org:5000'
function subscribe(address, deviceToken) {
if (!address || !deviceToken) {
throw new Error(`Cant subscribe without address or device token`)
}
return fetch(serviceAPI + '/subscribe', {
method: 'POST',
body: JSON.stringify({
address,
deviceToken,
})
})
.then(res => res.text())
}
function parseURLParams(location) {
var query = location.search || "?"
var params = query.slice(1).split("&").map((str) => str.split("=")).reduce((obj, [key, value]) => ({ [key]: value, ...obj }), {})
console.log('params', params)
return params
}
function redirectTo(uri) {
console.log('redirect to', uri)
try {
window.location = uri
} catch (err) {
console.error(err)
}
}
function printQR(data) {
document.querySelector('#link').href = data
document.querySelector('#qrcode').innerText = data
}
var params = parseURLParams(window.location)
if (!params.address) {
handleError()
}
if (params.chain == 'bitcoin' || !params.chain) {
subscribe(params.address, params.deviceToken)
.then(success => {
console.log('res', success)
redirectTo('flightwallet://subscribed')
})
.catch(err => {
alert(err.message)
console.error(err)
})
} else if (params.chain == 'ethereum') {
alert('We dont support ETH subscription service yet, sorry')
}
</script>
</head>
<body>
<div class="container" style="max-width: 700px; margin: 0 auto;">
<h1>Subscribe to PUSH updates</h1>
<a id="link" href="flightwallet://openapp">Open in app</a>
<p>
Please open this page with parameters:
<p>
<a href="https://flightwallet.org/subscribe?address=YOUR_ADDRESS&deviceToken=YOUR_DEVICE_TOKEN">
https://flightwallet.org/subscribe?address=YOUR_ADDRESS&deviceToken=YOUR_DEVICE_TOKEN
</a>
<ul>
<li>
YOUR_ADDRESS – Copy Bitcoin Testnet address from Wallets page
<li>
YOUR_DEVICE_TOKEN - Shake your phone on Wallets page and it'll present you the device token, and copy it into the clipboard
</ul>
<div id="qrcode"></div>
</div>
</body>
</html>