0

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().

  • Please see this https://stackoverflow.com/a/53928862/1731626 – Sergio Dec 18 '22 at 22:11
  • This is not the same question, please remove that, I ve tried the examples and still not working –  Dec 19 '22 at 22:02
  • Have you tried to call the suspend function within a coroutine? Please give an example, update the question, and I will revise. – Sergio Dec 20 '22 at 07:23

0 Answers0