Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Android: Email Link Authentication. intent-filter not working

I'm implementing the firebase Email Link Authentication Mechanism for Android. I have implemented it using the guide by firebase. But now after opening link from email the app always goes to launcher activity. I'm not able to debug the issue. I have also dynamic link implemented in my app and that works fine. Here is my intent filter:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />

    <data android:scheme="http" />
    <data android:scheme="https" />
    <data android:host="www.example.com" />
    <data android:pathPrefix="/emailSignInLink" />

</intent-filter>

And here is the ActionCodeSetting I'm using:

ActionCodeSettings settings = ActionCodeSettings.newBuilder()
                .setAndroidPackageName(
                        BuildConfig.APPLICATION_ID,
                        false, /* install if not available? */
                        null   /* minimum app version */)
                .setHandleCodeInApp(true)
                .setUrl("https://www.example.com/emailSignInLink")
                .build();

Can anyone figure out what I'm doing wrong here or missing some thing

Sample from firebase:

https://github.com/firebase/quickstart-android/blob/master/auth/app/src/main/AndroidManifest.xml

https://github.com/firebase/quickstart-android/blob/master/auth/app/src/main/java/com/google/firebase/quickstart/auth/PasswordlessActivity.java

EDIT 1:

I checked by logging intent data in my launcher activity's onResume data and I'm getting the data returned by firebase authentication, so it looks like some kind of issue with Dynamic Link I think.

My version of firebase invites is 15.0.0 as 15.0.2 is giving me error (updated in docs but not actually released I think.)

implementation "com.google.firebase:firebase-invites:15.0.0"

EDIT 2: The same issue is also present when using the firebase sample for passwordless login example. I have created a issue on GitHub

https://github.com/firebase/quickstart-android/issues/488

like image 446
Umar Hussain Avatar asked May 04 '18 13:05

Umar Hussain


2 Answers

I just have the same problems as you. To solve it I remove the pathPrefix and set the url of my domain instead of the dynamic links in the intent filter and it seems to work.

 <intent-filter>
      <action android:name="android.intent.action.VIEW" />
      <data
           android:scheme="https"
           android:host="myfirebaseId.firebaseapp.com"/>
      <category android:name="android.intent.category.BROWSABLE" />
      <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Hoping it will help

like image 118
Skav Avatar answered Oct 16 '22 05:10

Skav


I had the same problem as you. I have solved it. In the manifest, in android:host I do put a Dynamic link domain!

Like thay said in https://firebase.google.com/docs/dynamic-links/android/receive

Note that the android:host must be set to your Dynamic Links domain, and not the domain of your deep link.

In Manifest:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.BROWSABLE" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:host="myDynamicLink.page.link" android:scheme="https" />
</intent-filter>

In my secondery activity:

ActionCodeSettings actionCodeSettiongs = ActionCodeSettings.newBuilder()
        .setAndroidPackageName(getPackageName(), false, null)
        .setHandleCodeInApp(true)
        .setUrl("https://auth.example.com")
        .build();

The generated URL for my email then like: "https://myDynamicLink.page.link/?link=https://myApp.firebaseapp.com...continueUrl%3Dhttps://auth.example.com..."


P.S. This all confusing because they in their Guids as an example put link "https://example.com", not a "http://example.page.link"

like image 35
Anton Fedorych Avatar answered Oct 16 '22 04:10

Anton Fedorych