Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit a5b6b1c

Browse files
authored
Merge pull request #900 from TwilioDevEd/add-conversations-reachability
Add reachability JS snippet for Conversations
2 parents 6f9a7bf + db1709d commit a5b6b1c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"title": "Handle Reachability updates on client side",
3+
"description": "Handle an UpdateReason change and process the Reachability Indicators",
4+
"type": "mobile"
5+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// function called after client init to set up event handlers
2+
function registerEventHandlers() {
3+
user = conversationsClient.user;
4+
// Register User updated event handler
5+
user.on('updated', function(event) {
6+
handleUserUpdate(event.user, event.updateReasons)
7+
});
8+
}
9+
10+
// function to handle User updates
11+
function handleUserUpdate(user, updateReasons) {
12+
// loop over each reason and check for reachability change
13+
updateReasons.forEach(function(reason) {
14+
if (reason == 'online') {
15+
//do something
16+
}
17+
});
18+
}

0 commit comments

Comments
 (0)