@@ -9,30 +9,44 @@ import io.getstream.chat.android.client.logger.ChatLogLevel
99import io.getstream.chat.android.client.models.User
1010import io.getstream.chat.android.compose.ui.channels.ChannelsScreen
1111import io.getstream.chat.android.compose.ui.theme.ChatTheme
12- import io.getstream.chat.android.offline.ChatDomain
12+ import io.getstream.chat.android.offline.model.message.attachments.UploadAttachmentsNetworkType
13+ import io.getstream.chat.android.offline.plugin.configuration.Config
14+ import io.getstream.chat.android.offline.plugin.factory.StreamOfflinePluginFactory
1315
1416class MainActivity : AppCompatActivity () {
1517
1618 override fun onCreate (savedInstanceState : Bundle ? ) {
1719 super .onCreate(savedInstanceState)
1820
19- // 1 - Set up the client for API calls and the domain for offline storage
21+ // 1 - Set up the OfflinePlugin for offline storage
22+ val offlinePluginFactory = StreamOfflinePluginFactory (
23+ config = Config (
24+ backgroundSyncEnabled = true ,
25+ userPresence = true ,
26+ persistenceEnabled = true ,
27+ uploadAttachmentsNetworkType = UploadAttachmentsNetworkType .NOT_ROAMING ,
28+ ),
29+ appContext = applicationContext,
30+ )
31+
32+ // 2 - Set up the client for API calls and with the plugin for offline storage
2033 val client = ChatClient .Builder (" b67pax5b2wdq" , applicationContext)
34+ .withPlugin(offlinePluginFactory)
2135 .logLevel(ChatLogLevel .ALL ) // Set to NOTHING in prod
2236 .build()
23- ChatDomain .Builder (client, applicationContext).build()
2437
25- // 2 - Authenticate and connect the user
26- val user = User (id = " tutorial-droid" ).apply {
27- name = " Tutorial Droid"
38+ // 3 - Authenticate and connect the user
39+ val user = User (
40+ id = " tutorial-droid" ,
41+ name = " Tutorial Droid" ,
2842 image = " https://bit.ly/2TIt8NR"
29- }
43+ )
3044 client.connectUser(
3145 user = user,
3246 token = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidHV0b3JpYWwtZHJvaWQifQ.NhEr0hP9W9nwqV7ZkdShxvi02C5PR7SJE7Cs4y7kyqg"
3347 ).enqueue()
3448
35- // 3 - Set up the Channels Screen UI
49+ // 4 - Set up the Channels Screen UI
3650 setContent {
3751 ChatTheme {
3852 ChannelsScreen (
0 commit comments