Skip to content

Instantly share code, notes, and snippets.

@rahulvramesh
Last active February 28, 2020 17:48
Show Gist options
  • Select an option

  • Save rahulvramesh/e0ea9f4230f60e49fbaa128d48a0b3ce to your computer and use it in GitHub Desktop.

Select an option

Save rahulvramesh/e0ea9f4230f60e49fbaa128d48a0b3ce to your computer and use it in GitHub Desktop.
Twilio Chat
fetch('https://atrom.accubits.com/chat/token', {
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' },
method: 'POST',
body: JSON.stringify({"identity":"rahulvamesh"})
})
.then(res => res.json())
.then(data => Chat.create(data.token))
.then(this.setupChatClient)
.catch(this.handleError);
client.createChannel({
uniqueName: "Some Random Key",
friendlyName: "Accubits Public Channel"
}).then(function(channel) {
// channel created
})
.catch(error => console.log(error));
client.getChannelByUniqueName("UID For Channel")
.then(function(myChannel) {
//join the channel
myChannel.join()
.then(function(currentChannel) {
//success
}) .catch(() => {})
client.getChannelByUniqueName(channelUID)
.then(function(myChannel) {
myChannel.invite("ABC").then(function() {
console.log('Your friend has been invited!');
});
})
myChannel.typing();
myChannel.sendMessage("This is test message").then(function() {
console.log();
}).catch(error => console.log(error));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment