Build your chat to use encrypted, self-destructing messages by simply:
Importing the Babel, PubNub, and Cryptico SDKs
Initializing an instance of Babel
It’s as simple as that to get started! For additional details to build this app, check out our five-part blog series.
<script src="pubnub.js"></script> <script src="cryptico.js"></script> <script src="babel.js"></script> <script> var babel = new Babel('me'); </script>
Babel uses 1024-bit RSA encryption to secure every message that it sends. You can get an object of all users and their respective keys using the
listUsers() call or get your own Cryptico RSAkey with
The basic building blocks to sending and receiving Babel messages are:
||This sends the message string to the recipient provided. The ttl specifies the number of seconds the message will be available before it self-destructs.|
||This call returns all messages that haven’t self-destructed yet.|
||This allows you to specify a callback that should be called when you receive a message.|
PubNub Presence allows you to detect when users enter or leave your app. With Babel, you can find all users currently connected to your chat using the
listUsers() call. The callback within
onPresence(callback) will be called whenever a user joins or leaves. For a more detailed overview of the Babel API, check out the README on GitHub.
Need help? Contact PubNub Support.