Search code examples
javaandroidfacebook-sdk-4.x

Facebook deferred deep linking not working


How can I get the app link data if my app wasn't installed when the user tapped a deep link in the facebook app? There is surprisingly little documentation from facebook on this issue. Here is the manifest content of deep link class.

<activity
            android:name=".ui.activities.ViewProductSimple"
            android:label="Clicky Online Shopping App"
            android:launchMode="singleTask"
            android:screenOrientation="portrait" >

            <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="www.clicky.pk" android:scheme="http"/>
                <data android:host="www.clicky.pk" android:scheme="https"/>
            </intent-filter>

        </activity>

This is my deep link: https://www.clicky.pk/index.php/dispatch=products.view%26product_id=268522

Thats is the ViewProductSimple class from where am getting the deep link.

FacebookSdk.sdkInitialize(getApplicationContext());
    Uri targetUrl = AppLinks.getTargetUrlFromInboundIntent(this, getIntent());
    if (targetUrl != null)
    {
        Log.i("Activity", "App Link Target URL: " + targetUrl.toString());
        Toast.makeText(this, targetUrl.toString(), Toast.LENGTH_SHORT).show();
        String scheme = targetUrl.getQueryParameter("dispatch");
        String id = scheme.substring(25);
        productId = Integer.parseInt(id);
        getProductFromServer();
    }

Problem is when i send deep link through "App Ads Helper" i get notification in Facebook, if app install it work perfectly but if app not install then it bring me to play store and after installing it just open the MainActivity. Could anyone help me out? am stuck somewhere in deep link and i want to prompt my app through deep linking. Any code or example would be highly appreciate.


Solution

  • You need to get data from FacebookDeeplink in launch Activity (MainActivity), it is the same way that you got it in ViewProductSimple. Because then the user install your app and open your app, the facebook deeplink will be sent to MainActivity (launch activity).