After User clicks on the link from email for email link based authentication, the user is not redirected to desired activity in the app. Instead of opening the activity with the intent filter (in auth sample PasswordlessActivity.java) it opens the launcher activity which has the data in its intent.
Its happening with the code sample in the auth app (no changes, just the url for ActionCodeSettings, intent filter and google-services.json file).
mark
@umarhussain15 are you still having this issue? Can you show the code changes you made.
Yes the issue is still present, I just made changes to the auth sample for enabling the password less activity.
ActionCodeSettings to match the url in the above intent-filter.@umarhussain15 you have me a bit stumped to be honest! Does the sample app work on your device or no?
it does work but as I mentioned earlier, the flow of PasswordLessActivity.java is broken.
After user clicks on the link in email it should open the PasswordlessActivity as this activity has intent-filter set according to Firebase docs. But instead the Activity for choosing authentication method is started.
You can replicate it in the app just by setting up the auth sample with firebase project as given in the instructions for the project.
@umarhussain15 there must be something a bit different in your setup as I can't replicate this with the sample app in this repo on my Pixel. I even force-stopped the app before clicking on the link in my email and the deep link goes right to PasswordlessActivity rather than the picker screen.
Can you try this on a device other than the OnePlus? Maybe an emulator?
@samtstern I tried it on emulator (Android emulator with API 26 and Google play store) but still the PasswordlessActivity is not opening.
I even changed the firebase project and setup the app with it but still it goes to picker activity.
Can you outline steps you did to have successful flow?
I'm running into this same issue on my own app. It seems like the intent filter doesn't recognize the dynamic link, so it just starts my launcher activity instead.
I'm sending the link with:
val actionCodeSettings = ActionCodeSettings.newBuilder()
.setAndroidPackageName("<my-package-name>", false, null)
.setHandleCodeInApp(true)
.setUrl("https://auth.example.com/emailSignInLink")
.build()
FirebaseAuth.getInstance().sendSignInLinkToEmail(email, actionCodeSettings)
.addOnCompleteListener { task ->
// ...
}
I whitelisted auth.example.com in the console.
The activity with the intent filter is declared like this:
<activity
android:name=".signin.SignInActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.SignIn"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="https"
android:host="auth.example.com"
android:pathPrefix="/emailSignInLink" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
When I click the link in the email, the SignInActivity isn't started though... it just goes right to my default launch activity. When I log intent.getDataString() in onCreate() of my launcher activity, I'm seeing:
https://<my-app-name>.firebaseapp.com/__/auth/action?apiKey=<my-api-key>&mode=signIn&oobCode=<oob-code>&continueUrl=https://auth.example.com/emailSignInLink&lang=en
Tested on API 26 emulator & Pixel, and API 21 emulator.
A bit more information...
When I test the email link with adb, it links to the correct activity in my app, but when I click from gmail it just goes to my launch activity. This seems strange... doesn't clicking a link in gmail just start an ACTION_VIEW intent?
Here's what I'm typing into my terminal:
adb shell am start -W -a android.intent.action.VIEW -d <big long link from email>
@mattlogan1 thanks for the extra info. To be honest you have me stumped, are there any logs that let you see what the intent that Gmail is launching looks like? Maybe you could intercept it in the app and log it?
Appreciate the response @samtstern!
I have an open support thread going with Jonathan from Firebase Support where I explain this in a bit more detail... I'll paste my last message to him here:
In the documentation here it says "The intent filter should catch deep links of your domain, since the Dynamic Link will redirect to your domain if your app is installed," followed by an example of an intent filter for the domain "yoursite.example.com" (to be replaced with my domain of course).
But when I send the email sign-in link from my Android app, the email link looks like this:
https://uwh8z.app.goo.gl/?link=https://sessions-app.firebaseapp.com/__/auth/action?apiKey%3DAIzaSyAHwlSERM9SPlihrBtK-tEV8fYhaXlzV-k%26mode%3DsignIn%26oobCode%3Dnz200HCMiTS299AAdI-YiJHMFpveYIZ3WF47vaq_4cYAAAFj0hk1nw%26continueUrl%3Dhttps://www.apexpark.co/sessions/finishSignIn%26lang%3Den&apn=co.apexpark.sessions&afl=https://sessions-app.firebaseapp.com/__/auth/action?apiKey%3DAIzaSyAHwlSERM9SPlihrBtK-tEV8fYhaXlzV-k%26mode%3DsignIn%26oobCode%3Dnz200HCMiTS299AAdI-YiJHMFpveYIZ3WF47vaq_4cYAAAFj0hk1nw%26continueUrl%3Dhttps://www.apexpark.co/sessions/finishSignIn%26lang%3Den
You can see that the link portion of the query string in this URL has the sessions-app.firebaseapp.com domain, and NOT my custom domain of www.apexpark.co (that's in continueUrl instead).
When I click this link, my activity with the intent filter for the www.apexpark.co domain isn't opened. Instead, my main activity (default/launcher activity) is opened with an intent containing a URL of the domain sessions-app.firebaseapp.com. This URL works as a dynamic link!
And if I change my intent filter to use the sessions-app.firebaseapp.com domain instead of the www.apexpark.co domain, everything works as expected (that activity is launched), but this seems to go against the documentation! So I'm not sure if I'm doing something wrong or if the documentation is wrong.
That's the end of that email. To answer your question about logs, there is some info from ActivityManager in logcat that kind of shows what's happening when I click the link.
I/ActivityManager: START u0 {act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=https://uwh8z.app.goo.gl/... flg=0x14000000 pkg=com.google.android.gms cmp=com.google.android.gms/.appinvite.AppInviteAcceptInvitationActivity (has extras)} from uid 10051
I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] dat=https://sessions-app.firebaseapp.com/... flg=0x14800000 pkg=co.apexpark.sessions cmp=co.apexpark.sessions/.LaunchActivity (has extras)} from uid 10017
It looks like there's this AppInviteAcceptInvitationActivity from Play Services that handles the uwh8z.app.goo.gl intent, parses that URL, then starts some activity in my app. It seems like ideally this should be starting my SignInActivity which has the www.apexpark.co intent filter, but instead it's just launching my default/launcher activity with the sessions-app.firebaseapp.com domain.
If instead I change my SignInActivity intent filter to intercept the sessions-app.firebaseapp.com, everything works like it should and the sessions-app.firebaseapp.com URL is a valid dynamic link.
Sorry this is a lot of information! Really appreciate the help, even if this isn't the most appropriate forum!
Hi,
I just have the same problems as you guyz. I remove the pathPrefix and set the url of my domain instead of the dynamic links and it seems to work.
@mattlogan1 were you able to resolve this with Firebase support?
Unfortunately no, I haven't gotten any further response from them.
@mattlogan1 ok I found your case and will push it along, sorry about the delay.
@loicsiret your solution is working.
Just one question which url are you using during creation of action settings?
I'm adding /emailSignInlink during link creation but removed this in my intent filter.
@samtstern is this the solution firebase will be providing?
@samtstern any update on the issue?
The solution suggested by @loicsiret works only if one activity has the intent filter for the email link auth.
If I provide two activities with the same filter it opens a activity chooser to select.
My app requires two flows one for login one for sign up i.e. I need two unique urls for passwordless login.
Any update on the issue?
@umarhussain15 apologies I never got back to this. We are going to update the docs now.
TL;DR you do need to add an intent-filter for the firebaseapp URL.
See #676
Most helpful comment
Hi,
I just have the same problems as you guyz. I remove the pathPrefix and set the url of my domain instead of the dynamic links and it seems to work.