File tree Expand file tree Collapse file tree 4 files changed +299
-136
lines changed
java/com/firebase/ui/auth/compose Expand file tree Collapse file tree 4 files changed +299
-136
lines changed Original file line number Diff line number Diff line change 1616 <category android : name =" android.intent.category.LAUNCHER" />
1717 </intent-filter >
1818 </activity >
19+
20+ <!--
21+ Test activity for email link deep link handling.
22+ This handles ACTION_VIEW intents with email link URLs from the Firebase Auth Emulator.
23+ -->
24+ <activity
25+ android : name =" com.firebase.ui.auth.compose.testutil.EmailLinkTestActivity"
26+ android : exported =" false"
27+ android : launchMode =" singleTop" >
28+ <intent-filter >
29+ <action android : name =" android.intent.action.VIEW" />
30+ <category android : name =" android.intent.category.DEFAULT" />
31+ <category android : name =" android.intent.category.BROWSABLE" />
32+
33+ <!-- Handle emulator links (http://127.0.0.1:9099/...) -->
34+ <data android : scheme =" http" />
35+ <data android : scheme =" https" />
36+ <data android : host =" 127.0.0.1" />
37+ <data android : host =" fake-project-id.firebaseapp.com" />
38+ </intent-filter >
39+ </activity >
1940 </application >
2041
2142 <!-- No runtime permissions needed for unit tests -->
Original file line number Diff line number Diff line change 1+ package com.firebase.ui.auth.compose.testutil
2+
3+ import android.content.Intent
4+ import android.os.Bundle
5+ import androidx.activity.ComponentActivity
6+
7+ /* *
8+ * Test activity for handling email link deep links in tests.
9+ *
10+ * This activity is used in tests to properly simulate the Android deep link flow
11+ * where the app is launched with an ACTION_VIEW intent containing the email link.
12+ *
13+ * The activity simply extracts the email link from the intent and makes it available
14+ * via the [emailLinkFromIntent] property for verification in tests.
15+ */
16+ class EmailLinkTestActivity : ComponentActivity () {
17+
18+ /* *
19+ * The email link extracted from the deep link intent.
20+ * This will be populated when the activity is launched with an ACTION_VIEW intent.
21+ */
22+ var emailLinkFromIntent: String? = null
23+ private set
24+
25+ override fun onCreate (savedInstanceState : Bundle ? ) {
26+ super .onCreate(savedInstanceState)
27+ handleIntent(intent)
28+ }
29+
30+ override fun onNewIntent (intent : Intent ) {
31+ super .onNewIntent(intent)
32+ setIntent(intent)
33+ handleIntent(intent)
34+ }
35+
36+ private fun handleIntent (intent : Intent ? ) {
37+ if (intent?.action == Intent .ACTION_VIEW ) {
38+ emailLinkFromIntent = intent.data?.toString()
39+ }
40+ }
41+ }
Original file line number Diff line number Diff line change @@ -52,6 +52,20 @@ class EmulatorAuthApi(
5252 ? : throw Exception (" No VERIFY_EMAIL OOB code found for user email: $email " )
5353 }
5454
55+ fun fetchEmailSignInLink (email : String ): String {
56+ val oobCodes = fetchOobCodes()
57+ return (0 until oobCodes.length())
58+ .asSequence()
59+ .mapNotNull { index -> oobCodes.optJSONObject(index) }
60+ .lastOrNull { json ->
61+ json.optString(" email" ) == email &&
62+ json.optString(" requestType" ) == " EMAIL_SIGNIN"
63+ }
64+ ?.optString(" oobLink" )
65+ ?.takeIf { it.isNotBlank() }
66+ ? : throw Exception (" No EMAIL_SIGNIN OOB link found for user email: $email " )
67+ }
68+
5569 fun fetchVerifyPhoneCode (phone : String ): String {
5670 val payload =
5771 httpClient.get(" /emulator/v1/projects/$projectId /verificationCodes" ) { connection ->
You can’t perform that action at this time.
0 commit comments