facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 909 forks source link

Implement fetch deferred app link #813

Closed rnike closed 3 years ago

rnike commented 3 years ago

About

Using facebook deferred app link in react-native project was a bit painful, because it isn't included in react-native-fbsdk.

Simply warp the fetchDeferredAppLink function from native.

iOS

  1. Use fetchDeferredAppLink from FBSDKAppLinkUtility
  2. Convert app link url from NSURL to NSString if app link is found and pass it to JS using RCTPromiseResolveBlock.
  3. Resolve null if app link is not found.

Android

  1. Use fetchDeferredAppLinkData from AppLinkData
  2. If appLinkData is found, convert its Uri to String and pass it to JS using com.facebook.react.bridge.Promise.
  3. Resolve null if appLinkData is not found.

Test Plan:

Check if AppLink.fetchDeferredAppLink is working as expected

Example code

import { AppLink } from 'react-native-fbsdk';

const link = await AppLink.fetchDeferredAppLink();

console.log(link); // should be a string or null
inveon-yakupdurmus commented 3 years ago

I can get data when I send a deferred deep link for applink from the test page. But when I click on a created ad, the deep link comes NULL even though I am directed to the application.

I publish the ad from the Facebook Ad management and add it to my Facebook stream. When I click on the ad, it goes to the app. But since the application comes with NULL, I cannot direct it to product details.

I can get data when I send a deferred deep connection on the test screen.

How can I solve this problem.