@@ -77,10 +77,10 @@ class FirebaseAuthActivity : ComponentActivity() {
7777 super .onCreate(savedInstanceState)
7878 enableEdgeToEdge()
7979
80- // Extract configuration from cache using UUID key
81- val configKey = intent.getStringExtra(EXTRA_CONFIGURATION_KEY )
82- configuration = if (configKey != null ) {
83- configurationCache.remove(configKey )
80+ // Extract configuration and auth instance from cache using UUID key
81+ val launchKey = intent.getStringExtra(EXTRA_CONFIGURATION_KEY )
82+ configuration = if (launchKey != null ) {
83+ configurationCache.remove(launchKey )
8484 } else {
8585 null
8686 } ? : run {
@@ -90,7 +90,16 @@ class FirebaseAuthActivity : ComponentActivity() {
9090 return
9191 }
9292
93- authUI = FirebaseAuthUI .getInstance()
93+ authUI = if (launchKey != null ) {
94+ authUICache.remove(launchKey)
95+ } else {
96+ null
97+ } ? : run {
98+ // Missing auth instance, finish with error
99+ setResult(RESULT_CANCELED )
100+ finish()
101+ return
102+ }
94103
95104 // Extract email link if present
96105 val emailLink = intent.getStringExtra(EmailLinkConstants .EXTRA_EMAIL_LINK )
@@ -191,14 +200,18 @@ class FirebaseAuthActivity : ComponentActivity() {
191200 */
192201 internal fun createIntent (
193202 context : Context ,
194- configuration : AuthUIConfiguration
203+ configuration : AuthUIConfiguration ,
204+ authUI : FirebaseAuthUI = FirebaseAuthUI .getInstance()
195205 ): Intent {
196206 val configKey = UUID .randomUUID().toString()
197207 configurationCache[configKey] = configuration
208+ authUICache[configKey] = authUI
198209
199210 return Intent (context, FirebaseAuthActivity ::class .java).apply {
200211 putExtra(EXTRA_CONFIGURATION_KEY , configKey)
201212 }
202213 }
214+
215+ private val authUICache = ConcurrentHashMap <String , FirebaseAuthUI >()
203216 }
204217}
0 commit comments