Skip to content Skip to sidebar Skip to footer

Unable To Query Parameters Stored In A Firebase Dynamic/deep-link

I'm creating a Firebase dynamic/deep link manually like this: Uri BASE_URI = Uri.parse('http://example.com/'); String packageName = getBaseContext().getPackageName(); Uri APP_URI =

Solution 1:

This i your url Uri APP_URI = BASE_URI.buildUpon().path(requestID.getText().toString().trim()+"%3DrequestID="+requestID.getText().toString().trim()+"%3Dextra1="+extra1.getText().toString().trim()+"%3Dextra2="+extra2.getText().toString().trim()).build();

If you decode this Url you are going to receive something like this

http://www.airbanq.com?name=45=extra1=45=extra2=12=extra3=455

This value %3D is equal to a =. To concatenate values in a query string you need to use this &, maybe you can try to avoid the encoding and decoding and try again. I suggested that option, in the other thread, because that was working fine to me with an older version of FIrebase.

That's the main reason behind of your null error, basically you are trying to get a query string from this http://www.airbanq.com?name=45=extra1=45=extra2=12=extra3=455

Create a link like this http://www.airbanq.com?name=45&extra1=45&extra2=12&extra3=455 and let me know. After this change with your code this will be works fine.

Update 1 I will share with you some code, hope this can solve your problem.

This code is based on what you have right now This first part is to create the URL and add some parameters as you can see

UriBASE_URI= Uri.parse("http://example.com/");

UriAPP_URI= BASE_URI.buildUpon().appendQueryParameter("requestID", "200").
                    appendQueryParameter("extra1", "value").
                    appendQueryParameter("extra2", "value").build();


StringencodedUri=null;
try {
   encodedUri = URLEncoder.encode(APP_URI.toString(), "UTF-8");
} catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
UrideepLink= Uri.parse("https://app.app.goo.gl/?link="+encodedUri+"&apn=com.xx.xx.dev");

This last part is just to receive the deeplink and read the values

AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink)
                .setResultCallback(
                        newResultCallback<AppInviteInvitationResult>() {
                            @OverridepublicvoidonResult(AppInviteInvitationResult result) {
                                Log.d(TAG, "getInvitation:onResult:" + result.getStatus());
                                if (result.getStatus().isSuccess()) {
                                    // Extract information from the intentIntentintent= result.getInvitationIntent();
                                    StringdeepLink= AppInviteReferral.getDeepLink(intent);
                                    StringinvitationId= AppInviteReferral.getInvitationId(intent);

                                    try {
                                        deepLink = URLDecoder.decode(deepLink, "UTF-8");
                                    } catch (UnsupportedEncodingException e) {
                                        e.printStackTrace();
                                    }
                                    Uriuri= Uri.parse(deepLink);
                                    StringrequestId= uri.getQueryParameter("requestID");
                                    StringrequestId2= uri.getQueryParameter("extra2");

                                    // Because autoLaunchDeepLink = true we don't have to do anything// here, but we could set that to false and manually choose// an Activity to launch to handle the deep link here.// ...
                                }
                            }
                        });

And finally this is the manifest

<activityandroid:name="com.google.firebase.quickstart.invites.MainActivity"android:label="@string/app_name"><intent-filter><actionandroid:name="android.intent.action.VIEW"/><categoryandroid:name="android.intent.category.DEFAULT"/><categoryandroid:name="android.intent.category.BROWSABLE"/><dataandroid:host="example.com"android:scheme="http"/><dataandroid:host="example.com"android:scheme="https"/></intent-filter></activity>

Hope this can solve your problems

Solution 2:

If you want to extract a text from the link text, use regex or get at specific indexof text. This is how you can get the data from invitation: Reference

Intentintent= result.getInvitationIntent();
StringdeepLink= AppInviteReferral.getDeepLink(intent);
StringinvitationId= AppInviteReferral.getInvitationId(intent);

and it s better to paste whole error message.

Post a Comment for "Unable To Query Parameters Stored In A Firebase Dynamic/deep-link"