Android client SDK
The Sending.Network Android SDK provides a messaging framework that enables you to integrate chatroom and notification services within your mobile applications. This quickstart will walk you through a simple demo that makes basic API calls like user registration, room creation, etc. Please refer to the SDK demo for the completed code.
Prerequisites
OS
Android 6.0 or above
Software
Android Studio 4.0 or above
Configure your build
Gradle
Add the following code to the top-level build.gradle configuration file:
buildscript {
ext.kotlin_version = "1.6.0"
repositories {
google()
jcenter()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}Add the sendingnetwork-android-sdk dependency in app module build.gradle file. Replace the x.y.z with the SDK version number.
If you intend to run a local P2P node, add the sendingnetwork-android-service as well. Replace the x.y.z with the SDK version number.
AndroidManifest.xml file
Your application should at least contain the provider InitializationProvider to remove the initialization of the WorkManager as below:
Initialization and DID login
Application initialization
Create SDNClient instance from the onCreate() method of the child class of Application.
Network configuration
There are two ways to join the SDN network. You can create a local P2P service to communicate with the SDN network. Or, you may connect to an existing Edge Node and enjoy the P2P messaging.
To connect to a remote Edge Node:
To run a local P2P node:
DID login
You will need a developer key to access the Edge Network. To request and utilize a developer key, please refer to the guide provided here.
The client calls the login-related APIs through AuthenticationService:
Query for existing DIDs associated with current wallet address.
Obtain login message by using one of the DIDs or the wallet address if no DID exists.
Request for a message signature with the developer key.
Request for a message signature with the user's wallet account.
Login by passing the two signatures to the edge node.
Your developer key server needs to perform the signing operation. Below is an example code for the client to request a signature from the server:"
Create a private chat
Invite a user to a private chat room with the user id.
Send and receive messages
Initiating Video Conference
Open a video conference by using the room ID.
Last updated