I've almost got the facebook login working but I'm...
# compose
j
I've almost got the facebook login working but I'm stuck in an android activity and can't get out. I've started and launched the activity, retrieved the token inside the activity callbacks but now I'm stuck with a token in the activity with no way to get it back out...
In compose land i have
Copy code
var loginIntent = Intent(user.context, FacebookLoginActivity::class.java)
val fbLoginInLauncher = rememberLauncherForActivityResult(
    contract = ActivityResultContracts.StartActivityForResult()
){ result: ActivityResult ->
    print("hello")  // this never hits
}
...
        Button(
            onClick = { launchSignIn(fbLoginInLauncher, loginIntent) },
            modifier = Modifier
                .padding(start = 40.dp, end = 40.dp, top = 10.dp, bottom = 10.dp)
                .fillMaxWidth()
        ) {
            Text("Login with facebook")
        }
...
fun launchSignIn(launcher: ManagedActivityResultLauncher<Intent, ActivityResult>, intent: Intent){
    launcher.launch(intent)
}
and in android activity land I have
Copy code
class FacebookLoginActivity() : Activity() {
    lateinit var callbackManager: CallbackManager

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        callbackManager = CallbackManager.Factory.create()
        var loginManager = LoginManager.getInstance()
        loginManager.registerCallback(callbackManager,
            object : FacebookCallback<LoginResult?> {
                override fun onSuccess(loginResult: LoginResult?) {
                    val token = loginResult?.accessToken?.token
//                  user.createFacebook(user, token)
                }
                override fun onCancel() {
                    // App code
                }
                override fun onError(exception: FacebookException) {
                    // App code
                }
            })
        loginManager.logInWithReadPermissions(this, listOf("email"))
    }

    override public fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        callbackManager.onActivityResult(requestCode, resultCode, data)
    }
}
How do I get my token out of here and back to compose land?