2

I'm developing an Android app where I have used Firebase Password Authentication to sign in users.

After users provide their email and password, I'm sending a verification e-mail using FirebaseAuth SDK.

/**  SEND A VERIFICATION MAIL TO THE USER **/
ActionCodeSettings.Builder settingBuilder  =  ActionCodeSettings.newBuilder();
String url = getString(R.string.link_mail_verification);

settingBuilder.setUrl(url).setHandleCodeInApp(true);

ActionCodeSettings settings = settingBuilder.build();

user.sendEmailVerification(settings).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {

if(task.isSuccessful()){

   Log.e("MAIL_VERIFICATION", "onComplete: mail verification sent" );

}else{
    // not sent

  }
 }
});

While verifying their email, I want users to be redirected in the app directly if it is installed, that's where I used Dynamic link

First, I started by creating a Dynamic Link in the firebase console enter image description here

Secondly I modified the firebase e-mail template to use my dynamic link as the action url. enter image description here

and in the e-mail sent to the user , some query parameters (e.g: oobCode, apiKey) are appended to the dynamic link. enter image description here

When the user clicks the above link, it correctly redirects to the app and open the activity that is registered to receive dynamic links.

My real problem is , how can I, from an Android application get all the query parameters present in the link sent to the user.

The methods that I tried so far, and didn't work : Method 1 : trying to get the query from Intent

FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent()).addOnSuccessListener(new OnSuccessListener<PendingDynamicLinkData>() {
        @Override
        public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {

            Uri deepLink = null;
            if(pendingDynamicLinkData != null){
                deepLink = pendingDynamicLinkData.getLink();
            }

            // trying to get from the intent
            if(deepLink != null){

                 Uri intentData = getIntent().getData();
                 if(intentData != null){

                     String code =  getIntent().getStringExtra("oobCode"); // always returns null

                 }
            }
        }
    });

Method 2: trying to get the query parameter from PendingDynamicLinkData

 FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent()).addOnSuccessListener(new OnSuccessListener<PendingDynamicLinkData>() {
        @Override
        public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {

            Uri deepLink = null;
            if(pendingDynamicLinkData != null){
                deepLink = pendingDynamicLinkData.getLink();
            }

            // trying to get from the deep link URI
            if(deepLink != null){

                String code = deepLink.getQueryParameter("oobCode"); // returns null too
            }
        }
    });

And the following is my manifest.xml

<activity
        android:name=".activities.MainActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <data
                android:host="@string/app_link_domain"
                android:scheme="https"
              />
        </intent-filter>

    </activity>
1
  • Just add this line of code var appLinkData: Uri? = intent.data in the Splash/Launcher screen. It will get data from your dynamic link. No need to add anything in manifest or implement FirebaseDynamicLinks function. And also add in Gradle implementation 'com.google.firebase:firebase-config:19.0.3'. It is working for me. Commented Aug 20, 2020 at 9:17

1 Answer 1

1

Not an official answer - just from my experience - query params appended to the dynamic link itself do NOT get passed to your deep link. Solution: if you want query params appended to your deep link (the actual url that users get directed to by the dynamic link) what you have to do is append these params in the creation of the dynamic link. In your case - instead of "https://leliberalpress.com/verification" you should have defined in the firebase console when creating the link: "https://leliberalpress.com/verification?some_param=some_value&another_param=some_other_value" The dynamic link itself stays without query params - ie remains: "https://leliberalpress.page.link/XktS"

Sign up to request clarification or add additional context in comments.

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.