-
Notifications
You must be signed in to change notification settings - Fork 0
/
call.html
35 lines (32 loc) · 1.14 KB
/
call.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
<html>
<head>
<title>Make Phone Calls</title>
<script src="C:/Users/rayan/node_modules/nexmo-client/dist/conversationClient.js"></script>
</head>
<body>
<p id="notification"></p>
<button type="button" id="call">Call</button>
<button type="button" id="hangup">Hang Up</button>
<script>
const USER_JWT = "USR-031095b2-87e2-411f-a7a9-5574a451e8a0";
let notification = document.getElementById("notification");
new ConversationClient()
.login(USER_JWT)
.then(application => {
notification.textContent = `You've logged in with the user ${application.me.name}`;
document.getElementById("call").addEventListener("click", () => {
application.callPhone("2132103009");
notification.textContent = `You're calling a phone number`;
})
application.on("member:call", (member, call) => {
notification.textContent = `You're in a call`;
document.getElementById("hangup").addEventListener("click", () => {
call.hangUp();
notification.textContent = "The call has ended";
})
})
})
.catch(console.log);
</script>
</body>
</html>