Skip to content

Instantly share code, notes, and snippets.

@hieuwu
Created August 1, 2023 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hieuwu/8bf6b6ce8602ff53a7e89b51eded5c62 to your computer and use it in GitHub Desktop.
Save hieuwu/8bf6b6ce8602ff53a7e89b51eded5c62 to your computer and use it in GitHub Desktop.
@AndroidEntryPoint
class DeepLinkHandlerActivity : ComponentActivity() {
@Inject
lateinit var supabaseClient: SupabaseClient
private lateinit var callback: (String, String) -> Unit
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supabaseClient.handleDeeplinks(intent = intent,
onSessionSuccess = { userSession ->
Log.d("LOGIN", "Log in successfully with user info: ${userSession.user}")
userSession.user?.apply {
callback(email ?: "", createdAt.toString())
}
})
setContent {
val navController = rememberNavController()
val emailState = remember { mutableStateOf("") }
val createdAtState = remember { mutableStateOf("") }
LaunchedEffect(Unit) {
callback = { email, created ->
emailState.value = email
createdAtState.value = created
}
}
ManageProductsTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
SignInSuccessScreen(
modifier = Modifier.padding(20.dp),
navController = navController,
email = emailState.value,
createdAt = createdAtState.value,
onClick = { navigateToMainApp() }
)
}
}
}
}
private fun navigateToMainApp() {
val intent = Intent(this, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
}
startActivity(intent)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment