This is a minimal sample app using just the Comapi Foundation SDK to provide messaging functionality.
- Signup for Comapi account here.
- Follow quickstart guide here and create an api space.
- Setup authentication for your apiSpace with the following values.
| Name | Value |
|---|---|
Issuer |
local |
Audience |
local |
Shared Secret |
secret |
ID Claim |
sub |
These same will be used in AuthChallengeHandler.java to create a JWT locally.
- Provide a value of
apiSpaceIdvariable in SampleApplication.class.
private void initComapi() {
...
// PUT YOUR API KEY HERE
final String apiSpaceId = "";
...
}You also need to put google-services.json file in foundation/sample/chat_sample folder. This is required for the app to build with the push messaging setup.
In order to create a Comapi session, you will need to create a profile within your apiSpace. Login dialog allows you to specify a profileId that you would like to use. The authentication mechanism is dealt with entirely in the app to simplify this example.
When you launch this app you will see the login dilog. Enter a profileId and you will be redirected to the conversation list view.
This Activity displays a list of conversations and allows you to drill into a particular one. You can create a new conversation by clicking the floating button at the bottom right.
This Activity displays a single conversation and allows you to send messages to it.
You can add / remove paritcipants for this conversation by clicking action button at the top right. The corresponding Activity will display current list of participants and allow adding/removing existing users to the conversation participant list.
Here is a good way to test out the functionality of this test app with a multi user conversation:
-
Install the app on two different devices
-
Login to the app using different profileId's on each device.
-
Create a conversation on one of the devices.
-
On the same device, add the other user as a participant.
-
The conversation should appear on the other device conversation list.
-
Open the conversation detail Activity on both.
-
Start sending mesages back and forth.