Integrating Push Chat
Integrating Push Chat for any functionality is extremely easy. The Push Chat SDK is divided into the following functionalities:
Each User of Push Chat has a PGP key which is either created locally or stored encrypted on Push nodes.
You are required to get the PGP key and decrypt it locally for which you can use the following SDK functions:
- This function will return all the user information, like the PGP keys. It takes as arguments the address of the wallet and the environment variable.
b. To create the User
- This function will create a new user and return the created user’s information, like the PGP keys. It takes as arguments the address of the wallet and the environment variable.
All chats for a user or all chats request for a user can be fetched in a paginated fashion using the following SDK functions:
a. To Fetch a list of all chats of a User
- This function returns all the latest chats from each address the caller is talking to. It’s used to build the inbox on a chat application for an address
b. To Fetch a list of all chats request of a User
- This function returns all the requests that wallet addresses sent to a particular address. In Push Chat, the receiver of the messages must always approve the request to start the chat with the other address.
Each conversation between the users or group of users have a conversation hash which is a linked list of thread that contains the encrypted chat messages stored on IPFS, the SDK does the work of decryption, etc provided you give the SDK a conversation hash.
a. Getting conversation hash of a single chat
- This function returns the conversation hash of the latest message exchanged between the user and the conversation.
b. Getting the History of a single chat
- This function takes as
an theargument the conversation hash from a message and the pagination and then returns the message content decrypted.
c. Getting just the latest message from a single chat
- This function takes as an argument the conversation hash from a message and then returns the message content decrypted.
theReplying chats require the user to approve the request if it's the first time and then interact normally via the send rest API call.
a. To approve a chat request (only required for first time)
- When receiving a Request, call this function to approve the request so you can start talking back to the address.
b. To chat with a user or conversation id
- Use this function to send messages to other addresses.