-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
42 lines (37 loc) · 1.32 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
<html>
<head>
<title>Receive Phone Calls</title>
<script src="./node_modules/nexmo-client/dist/nexmoClient.js"></script>
</head>
<body>
<p id="notification"></p>
<button type="button" id="answer">Answer</button>
<button type="button" id="reject">Reject</button>
<button type="button" id="hangup">Hang Up</button>
<script>
const USER_JWT = "YOUR USER JWT";
let notification = document.getElementById("notification");
new NexmoClient()
.createSession(USER_JWT)
.then(application => {
notification.textContent = `You've logged in with the user ${application.me.name}`;
application.on("member:call", (member, call) => {
notification.textContent = `You're receiving a call`;
document.getElementById("answer").addEventListener("click", () => {
call.answer();
notification.textContent = `You're in a call`;
})
document.getElementById("reject").addEventListener("click", () => {
call.reject();
notification.textContent = `You rejected the call`;
})
document.getElementById("hangup").addEventListener("click", () => {
call.hangUp();
notification.textContent = "The call has ended";
})
})
})
.catch(console.log);
</script>
</body>
</html>