0

I have applied firebase dynamic link and when i click on the link it opens in the browser. In the firebase console i created few dynamic links but when i build link in the app, i dont specify the url but the dynamic link domain obviously. The problem is that in all the created links in the console, i have specified my app to be opened and not the browser.

Main Activity code:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        button = (Button) findViewById(R.id.button);



        FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())
                .addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
                    @Override
                    public void onSuccess(PendingDynamicLinkData data) {
                        if (data == null) {
                            Log.d("NULL DATA  ", "getInvitation: no data");
                            return;
                        }

                        // Get the deep link
                        Uri deepLink = data.getLink();
                        String requestId2 = deepLink.getQueryParameter("extra1");


                        // Handle the deep link
                        // [START_EXCLUDE]
                        Log.d("DEEP LINK URL  ", "deepLink:" + deepLink);
                       if (deepLink != null) {

                            if(requestId2 == "value") {
                                        Intent intent = new Intent(getApplicationContext(), Main2Activity.class);

                                        startActivity(intent);
                                    }
                        }
                        // [END_EXCLUDE]
                    }
                })
                .addOnFailureListener(this, new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception e) {
                        Log.w("onFailure:  ", "getDynamicLink:onFailure", e);
                    }
                });



        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                //Uri BASE_URI = Uri.parse("https://example.com");

                Uri BASE_URI = Uri.parse("https://in.example.com");

                Uri APP_URI = BASE_URI.buildUpon().
                        appendQueryParameter("extra1", "value").build();


                String encodedUri = null;
                try {
                    encodedUri = URLEncoder.encode(APP_URI.toString(), "UTF-8");
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
                String domain = "abcd.app.goo.gl";

                DynamicLink.Builder builder = FirebaseDynamicLinks.getInstance()
                        .createDynamicLink()
                        .setDynamicLinkDomain(domain)
                        .setLink(APP_URI);


                DynamicLink link = builder.buildDynamicLink();

                Log.v("ENCODED URI: ", encodedUri);

                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("text/plain");
                intent.putExtra(Intent.EXTRA_EMAIL, "");
                intent.putExtra(Intent.EXTRA_SUBJECT, "GET TICKETS" );
                intent.putExtra(Intent.EXTRA_TEXT, "Click here : " + link.getUri().toString());

                startActivity(Intent.createChooser(intent, "Send Email"));
            }
        });


    }

Android Manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.firebasetest">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <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="example.com"
                    android:scheme="https"/>
            </intent-filter>



        </activity>
        <activity android:name=".Main2Activity">

        </activity>
    </application>

</manifest>

Before this i built the deep link manually without adding parameters and it was working fine. Since i had to add parameters, i used buildDynamicLink();

L3G3NDj
  • 35
  • 9
  • Can you share FDL link that you are using? Also check out debug resources here https://firebase.google.com/docs/dynamic-links/debug – Oleksiy Ivanov Oct 19 '17 at 23:13
  • From our Android engineer: It looks like the issue is that the AndroidParameters haven't been set. You will want to call setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build()) to the Builder to target it to the calling app. https://firebase.google.com/docs/dynamic-links/android/create has an example in the "Create a Dynamic Link from parameters" section. – Oleksiy Ivanov Oct 25 '17 at 17:17

0 Answers0