Search code examples
androidfacebookdeep-linkingapplinks

DeepLink opens app but callback in not firing until the app goes to background


EDITED:

Right now my only issue with deep linking is that whenever i click deeplink and My application is not running it will open my HomeActivity and deeplinked Activity in background. If i press back button from HomeActivity my app minimizes and when i start it again deeplink Activity gets called only then and is redirected to correct Activity.

Hello Everyone I want to implement Facebook deep linking from this reference https://developers.facebook.com/docs/app-ads/deep-linking. and i was successful with it but if my app is not running, it just redirects me to home screen when clicking deeplink from Facebook app. I can't seem to find solution to it can anyone help me out?

I have followed step by step instructions:

Created FB app Added FB sdk to Android app When I run the app, it is detected by Facebook, verified on the https://developers.facebook.com/tools/app-ads-helper/

<activity
        android:name=".activities.FacebookAdActivity"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme">

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

Solution

  • Your <data> tag in your AndroidManifest.xml should look like this -

    <data android:scheme="yourScheme" android:host="com.your.package"
                        android:pathPrefix="/FacebookAdActivity"/>
    

    In facebook provide the complete path yourScheme://com.your.package/FacebookAdActivity this should open the Ad Activity directly