Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.osocket:android-client:1.0.11'
}
kotlin
var osocket = OpenSocket(this);
osocket.setProjectConfig(project_id, client_id)
osocket.setDeveloperConfig(developer_id)
osocket.connect()
// You can change the priority of the notification
// osocket.setPriority(NotificationCompat.PRIORITY_HIGH)
java
OpenSocket osocket = new OpenSocket(this);
osocket.setProjectConfig(project_id, client_id);
osocket.setDeveloperConfig(developer_id);
osocket.connect();
onConnect, onReceiveToken, onReceiveMessage, onDisconnect, onConectionError
kotlin sample
osocket.onReceiveToken = {
Log.i("opensocket","service : onReceiveToken : $it")
}
osocket.onConnect = {
Log.i("opensocket","service : onConnect")
}
osocket.onReceiveMessage = {
Log.i("opensocket", "message:$it")
}