Setup & Authentication

Initialise the SDK

Before using the SDK, you will need to initialise the SDK with your API key. Please find your account API key in the Amity Social Cloud Console. The ideal place to do this is on application startup, in onCreate() method of Application class.

class SimpleChatApp : Application() {

    override fun onCreate() {
        super.onCreate()

        EkoClient.setup("YOUR_API_KEY")
    }
}

Authentication

You must first register the current device with a userId. A device registered with a userId will be permanently tied to that userId until you deliberately unregister the device, or until the device has been inactive for more than 90 days. A device registered with a specific userId will receive all messages belonging to that user.

public class HomeActivity extends AppCompatActivity {

    @Override
    public void onCreate() {
        super.onCreate();
        EkoClient.registerDevice("userId")
                         .displayName("name")
                         .authToken("token") // optional
       
    }
}

Last updated