<aside> 💡 Explore the Android project example featuring the integrated A-mates SDK on our GitHub repository. To run the project, you'll need a Community AppID. You can find your Community AppID by either accessing the Settings tab in the Community Management Panel or by signing up and creating a new Community Project.

</aside>

Integration

Step 1. Gradle Setup

// latest stable
amates_version = "1.2.9"

// Add repository
repositories {
    maven {
        url = "<https://gitlab.com/api/v4/projects/30687088/packages/maven>"
        credentials(HttpHeaderCredentials) {
            name = "Deploy-Token"
            value = "9KHq1shb9fWsDEeBtsH4"
        }
        authentication {
            header(HttpHeaderAuthentication)
        }
    }
}

dependencies {
    implementation("com.amates:amates:$amates_version")
    implementation("com.amates:amates-firebase:$amates_version") // for FCM support
    implementation("com.amates:amates-glide:$amates_version") // Optional for GlideImageLoader
}

Step 2. Init SDK

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Amates.init(application = this,
            appId = "YOUR_COMMUNITY_APP_ID_HERE", // your Community APP_ID
            domainConfig = DomainConfig.createAmatesDomainConfig(),
            fileProviderAuthorities = "com.yourdomain.fileprovider",
            imageLoader = GlideImageLoader(),
						profileConfig = YourAppProfileConfig(),
            styleConfig = SimpleStyleConfig(
                notificationIcon = R.drawable.ic_notification,
                nightMode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
            ),
						localeConfig = LocaleConfig.English.language,
            firebasePushTokenProvider = YourFirebasePushTokenProvider(),
            loggers = listOf(LogcatLogger()))
    }
}

<aside> 💡 To locate your Community AppID, simply navigate to the Admin Panel's Settings tab. Example of community AppID: 8211900d-537e-424b-9aa3-bbce0c5e498e

</aside>

Ensure that you have included the class name in the application tag within the Android Manifest.

<manifest>
 ...
<!-- Add Application class name to application tag in Android Manifest -->
<application
        android:name=".App"
      >
 ...
   </application>
</manifest>

userName and userID (Optional)

If your app's users have their own nicknames, you can provide them to A-mates to automatically synchronize the user's name with their A-mates name. If your app's users do not have their own names, you can skip this step. A-mates will generate the user's name automatically.

If you want the user to access their A-mates profile after clearing the cache, accidentally deleting the app, or switching to a new phone, you can retrieve the user's A-mates ID and save it on your server.

To link A-mates profile name and your user profile name, and to authorize the existing user, we have two fields: userName and userId.

userName is used for the first-time user entrance to the community.

After creating a user in A-mates, you will receive a userId that can be used to restore the user's A-mates profile.

Below is an example of such a profile configuration:

/
 * Your implementation that allows users to link their A-mates profile with your profile for seamless synchronization across multiple devices.
 */

class YourAppProfileConfig : ProfileConfig {

    private var receivedUserId: Int? = null

    /
     * Provide userId, if the user already has one to prevent A-mates from registering a new user.
     */
    override val userId: Int?
        get() = receivedUserId

    /**
     * Provide userName, so that A-mates can register a new user with that specific name
     */
    override val userName: String
        get() = "My unique nickname"

    override fun onUserIdReceived(id: Int) {
        // Store id in your profile for restoration of A-mates profile on other devices by the same user.
        receivedUserId = id
    }
}

Both userId and userName fields are not mandatory. When userName is not specified, A-mates will generate usernames like "user123" by default. Users have the ability to modify community nicknames on the Profile screen. Nicknames set by users in the Profile section will take precedence over the transferred userName.

fileProviderAuthorities