androidhttp-redirectgoogle-cloud-firestorefirebase-authenticationpassword-less

Firebase - Dynamic Link not working with Android 12


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);
        }
    });

Solution

  • 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>