-
Notifications
You must be signed in to change notification settings - Fork 30
Chat Client Implementation Notes
This page contains implementation notes for iOS and Android chat applications wishing to add ChatSecure-Push push messaging.
Our intention is that adding ChatSecure-Push's capabilities to your application should have no visible impact to your users until a push message arrives.
You should create a single ChatSecure-Push account for every application install. APNS and GCM issue one push token per application install so your app will use a single ChatSecure-Push account even if it allows the user to be present as multiple chat (XMPP etc.) accounts.
You should request an APNS or GCM push token on each application launch and notify ChatSecure-Push by creating or updating a Device entity.
You should request batches of Whitelist tokens from the server and distribute them to users you trust to send you push messages. A good time to do this might be during the initialization of a "conversation" view with a peer. Whitelist tokens should be sent and received automatically without any user interaction.
They should be exchanged via an end-to-end secure channel, such as a specially defined OTR TLV when you enter an OTR session. The token exchange process should also include information about the REST API endpoint, so the receiver knows where the POST your token.
These tokens can also be used in conjunction with the XEP-0357 push notifications XMPP extension, but we will focus on that in a future document.
We have chosen the following OTR TLVs for exchange of Whitelist token data:
0x01A4
= Whitelist token exchange
{
"endpoint": "https://push.chatsecure.org/api/v1/message",
"tokens": ["1daf13e01982d3029cf09ae3d027a62923f0f2b6"],
"date_expires": ["yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z"],
"extra_data": "anything goes!"
}
Sender:
- Request batch of tokens from server.
- Establish OTR session with a friend.
- Create JSON containing one or more whitelist tokens.
- Send the JSON data blob inside an OTR TLV (type=
0x01A4
)
Receiver:
- Establish OTR session with friend.
- Receive JSON blob within OTR TLV (type=
0x01A4
) - Extract whitelist
tokens
andendpoint
from JSON blob, save them locally, associated with your friend. - When desired, send a push to your friend by POSTing a
token
to the designatedendpoint
.
In its current form, ChatSecure-Push messages are best employed as a "knock" informing an offline user that someone would like to chat with them. As such you'd ideally present UI for "Knocking" an offline user from your app's "conversation" view.