I'm trying to implement a facebook login flow with...
# android
j
I'm trying to implement a facebook login flow with jetpack compose, unfortunately I'm having issues with getting
rememberLauncherForActivityResult
to hit. What I have gotten to work is to write my own activity class to handle the facebook callback and I'm able to get the token from facebook. The problem is I don't know how to pull the token out of an activity as I can't pass any callbacks into the activity... I was looking into maybe using a broad cast receiver to send the token out of the activity result back to the jetpack compose code. I'm newish to android so unsure if the broadcast receiver is the best way to do this? Is there better ways to send a string out of an activity than that?
So it looks like I should use putExtra to set a key/string pair. In my activity
Copy code
override fun onSuccess(loginResult: LoginResult?) {
    val token = loginResult?.accessToken?.token
    intent.putExtra("token", token)
}
I set the putExtra to token. In my compose code I start a thread waiting for the token to be set
Copy code
Thread {
    while (intent.getStringExtra("token") == "") {
        val tok = intent.getStringExtra("token")
        Thread.sleep(1000)
    }
    val token = intent.getStringExtra("token")
}.start()
I verify with break points that the token is being sent but when I set the break point back in my thread the token is never set...
Alright that didn't work either. I just used a singleton to share data between the compose and activity which worked
202 Views