Skip to content
Shine Chen edited this page Nov 10, 2019 · 10 revisions

IMKit Android SDK v3.1

About IMKit

IMKit is a live chat platform solution, more detail please visit: https://imkit.io

Features

  • Room list / Chat room
  • Support text, sticker, image, video, audio, location message
  • Support reply message
  • URL detection and preview
  • Typing indicator
  • AndroidX

Requirements

  • Android SDK Version 16+
  • Android Studio
  • Gradle 3.1.4+

Gradle Settings

Add to your project root build.gradle

buildscript {
  dependencies {
    classpath "io.realm:realm-gradle-plugin:5.7.1"
    classpath 'com.google.gms:google-services:4.2.0'
  }
}

Add to your application modules' build.gradle

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

repositories {
    maven {
        // Change to official release repository
        url  "http://dl.bintray.com/brianfang/IMKit-SDK-V3"
    }
}

dependencies {
  ...

  implementation project(':imkit')
  implementation 'androidx.appcompat:appcompat:1.0.0'
  implementation 'com.google.android.material:material:1.0.0'
  implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
  implementation 'com.github.bumptech.glide:okhttp3-integration:4.10.0@aar'
  implementation 'com.github.bumptech.glide:glide:4.10.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
  annotationProcessor 'androidx.annotation:annotation:1.1.0'
  implementation 'com.google.android.exoplayer:exoplayer:r2.4.0'
  implementation 'com.google.firebase:firebase-messaging:12.0.0'
  implementation 'org.jsoup:jsoup:1.11.3'
  implementation "com.tonyodev.fetch2:fetch2:2.2.0-RC16"

  ...
}

apply plugin: 'com.google.gms.google-services'

AndroidManifest.xml

<service
    android:name="com.imkit.sdk.firebase.IMFirebaseMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

<provider
    android:authorities="{applicationID}.fileProvider"
    android:name="androidx.core.content.FileProvider"
    android:grantUriPermissions="true"
    android:exported="false">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
</provider>

Init SDK

Call IMKIT.init(getApplicationContext()) at app module for init IMKit SDK

Usage

IMKIT

IMKIT.init(Context context)

// Login IMKit with name
IMKIT.login(Activity activity, String name, final IIMKIT.Login callback)

// Login IMKit with accessToken and userInfomation
IMKIT.login(String accessToken, String userDisplayName, String userAvatarUrl, String userDescription, final IIMKIT.Login callback)

// Update user's accessToken
IMKIT.refreshToken(String accessToken)

// Logut IMKit
IMKIT.logout(IIMKIT.Logout callback)

// Uptaer userInformation
IMKIT.updateUser(String userDisplayName, String userAvatarUrl, String userDescription, final IIMKIT.UpdateUser callback) 

// Intent to roomList
IMKIT.showRoomList(final Activity activity, final FragmentManager fragmentManager, final int fragmentContainerId, int requestCode)

// Intent to chatRoom
IMKIT.showChat(Activity activity, String roomId, String title, int requestCode)

// Private chat
IMKIT.createRoomWithUsers(Context context, ArrayList<String> userIds, final IIMKIT.CreateRoom callback)

// Group chat
IMKIT.createRoomWithUser(Context context, String userId, final IIMKIT.CreateRoom callback)

// Get badge information
IMKIT.getBadge(final IIMKIT.Badge callback)

Customize UI

user can customize roomlist / chatroom / roomInfo at imkit module

- roomlist : com.imkit.CustomRoomListFragment
- chatroom : com.imkit.CustomChatFragment
- roomInfo : com.imkit.CustomRoomInfoFragment

APIs

Clone this wiki locally