I want to remove first from db then to do the logout.
But I receive the error: Suspension functions can be called only within coroutine body when calling the logout method
My logout method
suspend fun doLogout(token: String) {
val userId = appService.currentUser?.id
realm.write {
var user = query<UserInfo>("_id = $0", userId).first().find()
user = findLatest(user)!!.also {
it.FCMToken.removeAt(productIndex)
}
copyToRealm(user)
appService.currentUser?.logOut() // Suspension functions can be called only within coroutine body
}
}
Any easy way to solve this? I want first to remove from db then do the logOut().
I want first to remove from db then do the logOut().