I am trying to integrate facebook app links for my react-native app and unfortunately it doesn't seem to work as expected. First of all, I followed the instructions mentioned in the docs. So I used react-native-facebook-app-link and tried to verify it using the ads helper and I am unable to get the url.
This is the code I have added,
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:windowSoftInputMode="adjustPan"
android:exported="true">
<intent-filter>
<data android:scheme="sample" android:host="open"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
and I have added the key in the manifest file,
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled"
android:value="true"/>
and also I have implemented the method,
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppLinkData.fetchDeferredAppLinkData(this,
new AppLinkData.CompletionHandler() {
@Override
public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
Log.d("urls", String.valueOf(appLinkData));
}
}
);
}
Since, I am building the app using react native, in the app.js i have added the below code,
async componentDidMount () {
FacebookAppLink.initializeSDK();
const url = await FacebookAppLink.fetchUrl();
if(url){
console.log("FACEBOOOK URL: ", url)
}
}
Finally, I tried using the ads helper, enter image description here
However I am not receiving the URL. It gets redirected to the app but the url isn't printed in the console. And please note the steps I followed are,
- Uninstalled the app
- Generated the link and I got the notification in facebook
- Rebuild and install the app using android studio
- Then click on that link
I am not sure what I have done wrong. Some help will be greatly appreciated. Thanks in advance.