Last active
February 28, 2020 17:48
-
-
Save rahulvramesh/e0ea9f4230f60e49fbaa128d48a0b3ce to your computer and use it in GitHub Desktop.
Twilio Chat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| client.createChannel({ | |
| uniqueName: "Some Random Key", | |
| friendlyName: "Accubits Public Channel" | |
| }).then(function(channel) { | |
| // channel created | |
| }) | |
| .catch(error => console.log(error)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| client.getChannelByUniqueName("UID For Channel") | |
| .then(function(myChannel) { | |
| //join the channel | |
| myChannel.join() | |
| .then(function(currentChannel) { | |
| //success | |
| }) .catch(() => {}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| client.getChannelByUniqueName(channelUID) | |
| .then(function(myChannel) { | |
| myChannel.invite("ABC").then(function() { | |
| console.log('Your friend has been invited!'); | |
| }); | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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