-
-
Save skydoves/466dd0e99e3d18b162e728527bca164e to your computer and use it in GitHub Desktop.
stream_chat_initializer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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