I want to use the LocalCached data from SendBird SDK while the mobile is offline
I developed an application which uses the SendBirdChat SDK and I have this initialization process:
let localCachConfiguration = LocalCacheConfig(isEncryptionEnabled: false)
localCachConfiguration.maxSize = 256
localCachConfiguration.clearOrder = .messageCollectionAccessedAt
let sendbirdChatInitParams = InitParams(
applicationId: applicationId,
isLocalCachingEnabled: true,
logLevel: .verbose
)
sendbirdChatInitParams.localCacheConfig = localCachConfiguration
SendbirdChat.initialize(params: sendbirdChatInitParams)
SendbirdChat.connect(userId: username, authToken: userAccessToken) { (user, error) in
if let error = error {
debugPrint("[Sendbird][Service][Init][Error][\(error.localizedDescription)]")
CrashlyticsUtil.recordErrorCrashlytics(error: error)
completion?(false)
} else if let user = user {
debugPrint("[Sendbird][Service][Init][User][\(user.nickname)]")
completion?(true)
} else {
debugPrint("[Sendbird][Service][Init][Fail]")
completion?(false)
}
}
and when I close the application and open it again the cache is empty and the SendBirdSDK doest retrieve any thing
Fetching code:
if let collection = channel, collection.hasNext {
collection.loadMore(completionHandler: { channels, error in
if let errorHappened = error {
debugPrint("[Sendbird][Service][Offline][FetchChannel][Error][\(errorHappened.localizedDescription)]")
completion(nil)
return
}
completion(channels)
})
} else {
debugPrint("[Sendbird][Service][Offline][FetchChannel][Error][No Query]")
}
and I got this error: Request couldn\'t be generated properly.
also for the SDK it send this error SendbirdChat [2024-12-01 2:22:34 PM +0000] 🚨SendbirdChat instance hasn't been initialized.🚨
The version of the SDK i am using: 4.21.8