2

I am sending an authentication link to the user's email address using Android and Firebase. Everything works as expected with Android 9, 10, and 11, with both release and debug versions. However, when tapping on the authentication link on devices running Android 12, the browsers (I tried with several browsers) redirect to an error page "Invalid Dynamic Link, requested URL must be a parsable and complete DynamicLink, etc...", whereas the same link works on other devices. What am I missing?

Here's the code:

ActionCodeSettings actionCodeSettings =
            ActionCodeSettings.newBuilder()
                    .setUrl("https://appName.page.link")
                    .setHandleCodeInApp(true)
                    .setIOSBundleId("com.appName.ios")
                    .setAndroidPackageName(
                            "com.appName.android",
                            false, 
                            getResources().getString(R.string.min_version_android))
                    .build();

   
    FirebaseAuth auth = FirebaseAuth.getInstance();
    auth.sendSignInLinkToEmail(emailAddress, actionCodeSettings).addOnSuccessListener(new OnSuccessListener<Void>() {
        @Override
        public void onSuccess(Void unused) {
            Intent intent = new Intent(SignIn.this, CheckSignInInbox.class);
            startActivity(intent);
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            String msg = getTimestamp() + "Error in sendSignInLinkToEmail: " + e.getMessage();
            logErrorAndFirebaseCrash(SignIn.this, msg);
        }
    });

2 Answers 2

3

I found the cause of the issue. In the manifest, in order to make it work with Android 12 as well, I had to include in my intent-filter android:autoVerify="true", as follows:

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

     <data
         android:host="domainname.page.link"
         android:scheme="https" />

         <category android:name="android.intent.category.BROWSABLE" />
         <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Sign up to request clarification or add additional context in comments.

7 Comments

Saved my day! Had an older app (flutter v1.22) with Firebase passwordless sign-in that I needed to port to Android 12 and I just couldn't get the link to be opened in the app (instead in Play Store via the browser); this was the cause. Thanks!
Glad to hear it. Don't hesitate to accept the answer then, tks
In case someone is facing this issue and cannot find the issue, in my case, the change is that before in the "intent-filter" the "android:scheme" part was at the beginning, not it has to be at the end. So from this: ``` <data android:scheme="https" android:host="example.link.com"/> ``` To this: ``` <data android:host="example.link.com" android:scheme="https"/> ´´´ Hope it saves someone an entire day ;)
@Himani Changed target sdk to 32 that solved for me.
@Himani Add all sub domains host (long and short dynamic link) in the data tag in your intent filter declared in AndroidManifest.xml
|
0

If you target sdk 33 and still have the problem, check on firebase console your dynamic link details. You'll see there are different host for long and short dynamic link. Add both in your <data> in your <intent-filter> in your AndroidManifest.xml. It worked for me to add all sub domains in data tag.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.