Index - Qiscus-Integration/android-multichannel-widget GitHub Wiki
Multichannel Widget Mobile
This is comunity support for sdk implement Qiscus multichannel to your apps.
- For Android your apps must using androidx and requires minimum Android API 16 (Jelly Bean).
- iOS minimum version iOS 11.
Install
Android
First, you need to add URL reference in your .gradle project.
allprojects {
repositories {
...
maven { url "https://dl.bintray.com/qiscustech/maven" }
maven {
url "https://artifactory.qiscus.com/artifactory/qiscus-library-open-source"
}
}
}
Then in your app build.gradle you need add this.
dependencies {
...
implementation ('com.qiscus.integrations:multichannel-widget:0.0.8')
}
iOS
Podfile
Pod 'MultichannelWidget'
Setup
In this part you will need Qiscus Multichannel AppId. You can get the AppId here.
Android
First, initialize Multichannel in your application class.
/**
* appId (required) : your qiscus multichannel appid
*/
MultichannelWidget.setup(this, appId)
If you need some custom configuration like logging, notification, you can using this method
/**
* appId (required) : your qiscus multichannel appid
* config (optional) : custom config for multichannel widget
*/
val config = MultichannelWidgetConfig
.setEnableLog(true)
.setEnableNotification(false) //default true
.setNotificationListener(null)
.setRoomTitle("Custom Room Title") // default room name
.setRoomSubtitle("Custom Room Subtitle") // default member list
MultichannelWidget.setup(this, appId, config)
iOS
/*
appId (required) = Your multichannel appid
*/
MultichannelWidget.setup(appID: appid)
Initiate chat
Android
Start chatting can be done in single method, here is how you can do that
/**
* context (required) : context activity
* nama (required) : username
* userid (required) : userId from user
* avatar (optional) : user avatar
* extras (optional) : extra data (json)
* userProperties (optional) : user properties for multichannel (Map)
*/
MultichannelWidget.instance.initiateChat(context, name, userId, avatar, extras, userProperties)
iOS
/*
context (required) : context activity
nama (required) : username
userid (required) : userId from user
*/
MultichannelWidget.shared.initiateChat(userId: userId, username: username, callback: { target in
self.navigationController?.pushViewController(target, animated: true)
})
Push Notification
Android
first you need setup Firebase Cloud Messaging in your android App. You need register your server key to Qiscus Multichannel. For now, we can help you to add this to multichannel, just create ticket to Qiscus support and send your server key and app id.
In your app, you need to register FCM token to notify Qiscus Multichannel. For example
class FirebaseServices : FirebaseMessagingService() {
override fun onNewToken(p0: String) {
super.onNewToken(p0)
MultichannelWidget.instance.registerDeviceToken(p0)
}
}
to handle incoming message from Qiscus Multichannel you can do this
override fun onMessageReceived(message: RemoteMessage) {
super.onMessageReceived(message)
if (MultichannelWidget.instance.isMultichannelMessage(message)) {
return
}
}
By default, Multichannel widget just show notification. If you need more than that or you want to custom your notification. You can do that in config before init
val configMultichannel: MultichannelWidgetConfig =
MultichannelWidgetConfig.setEnableLog(BuildConfig.DEBUG)
.setNotificationListener(object : MultichannelNotificationListener {
override fun handleMultichannelListener(
context: Context?,
qiscusComment: QiscusComment?
) {
//do something here
}
})
Troubleshoot
Android
If you facing error like this
More than one file was found with OS independent path 'META-INF/rxjava.properties'
Just add this code in your app build.gradle
android {
.....
.....
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
}