Skip to content

Setup & Authentication

Emee Miano edited this page Jan 13, 2022 · 3 revisions

Compatibility

We are always working to enhance our existing UIKit. As a result, the minimum compatibility may vary for our previous version releases. Below is the compatibility list for our latest release. For a complete compatibility history of any given UIKit version, you may refer to our changelogs.

  • Amity-Social-Cloud-SDK - 5.8.0
  • Glide - 4.12.0
  • OKHTTP3 - 4.9.0
  • Retrofit2 - 2.50
  • Android Paging Data Library - 3.0.1
  • Room - 2.3.0
  • RxJava2 - 2.3.10
  • Gson - 2.8.10
  • Kotlin-std-lib - 1.5.10
  • Kotlin-coroutines - 1.5.0
  • Exo Player - 2.12.1

Initialize the SDK

Before using the SDK, you need to initialize the SDK with your API key. Please find your account API key in Amity Social Cloud Console.

After logging in Console:

  1. Click Settings to expand the menu.
  2. Select Security.
  3. In the Security page, you can find the API key in the Keys section.

class SimpleApp : Application() {

    override fun onCreate() {
        super.onCreate()

        AmityCoreClient.setup(
            apiKey = "apiKey", 
            httpEndpoint = AmityRegionalEndpoint.EU,  // optional param, defaulted as SG region 
            socketEndpoint = AmityRegionalEndpoint.EU // optional param, defaulted as SG region 
        )
    }
}

Specify Endpoints Manually (Optional)

You can specify endpoints manually via optional parameters. API endpoints for each data center are different so you need to adjust the endpoint accordingly.

We currently support multi-data center capabilities for the following regions:

Region Endpoint Endpoint URL
Europe AmityRegionalEndpoint.EU api.eu.amity.co
Singapore AmityRegionalEndpoint.SG api.sg.amity.co
United States AmityRegionalEndpoint.US api.us.amity.co

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();
        AmityCoreClient.registerDevice("userId")
                         .displayName("name")
                         .authToken("token") // optional
                         .build()
                         .submit()
                         .subscribe()
       
    }
}
Clone this wiki locally