Skip to content

Instantly share code, notes, and snippets.

@skydoves
Last active Aug 1, 2022
Embed
What would you like to do?
stream_chat_initializer
class StreamChatInitializer : Initializer<Unit> {
override fun create(context: Context) {
val logLevel = if (BuildConfig.DEBUG) ChatLogLevel.ALL else ChatLogLevel.NOTHING
val offlinePluginFactory = StreamOfflinePluginFactory(
config = Config(
backgroundSyncEnabled = true,
userPresence = true,
persistenceEnabled = true,
uploadAttachmentsNetworkType = UploadAttachmentsNetworkType.NOT_ROAMING
),
appContext = context
)
val chatClient = ChatClient.Builder(**YOUR API KEY**, context)
.withPlugin(offlinePluginFactory)
.logLevel(logLevel)
.build()
val user = User(
id = "stream",
name = "stream",
image = "https://placekitten.com/200/300"
)
val token = chatClient.devToken(user.id)
chatClient.connectUser(user, token).enqueue()
}
override fun dependencies(): List<Class<out Initializer<*>>> = emptyList()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment