'AppLink.fetchDeferredAppLink() always returns null in android and undefined in iOS

🐛 Bug Report

AppLink.fetchDeferredAppLink() always returns null in android and undefined in iOS.

To Reproduce

I use https://developers.facebook.com/tools/app-ads-helper to test the deep-link. Here i enter the uri-scheme of the app and checked both Send Notification & Send Deferred.

It shows two popup,

If i click on the notification which i received on the developer facebook account, it is opening the installed app, but the method AppLink.fetchDeferredAppLink() always returns null/undefined.

I tried uninstaling the app, then clicked on the deferred link, then installed and opened the app, still same.

Code Example

const fbsdkInit = (bool) => {
  if (bool) {
    Settings.setAdvertiserTrackingEnabled(bool).then(() => {
      Settings.initializeSDK();
      AppLink.fetchDeferredAppLink().then((link) =>
        console.log("Link 1", link)
      );
    });
  } else {
    Settings.initializeSDK();
    AppLink.fetchDeferredAppLink().then((link) => console.log("Link 2", link));
  }
};

async function getATTPermissionForFbAppEvents() {
  const ATT_CHECK = await check(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY);
  if (ATT_CHECK === RESULTS.DENIED) {
    try {
      const ATT = await request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY);
      if (ATT === RESULTS.DENIED) {
        getATTPermissionForFbAppEvents();
      } else {
        if (ATT === RESULTS.GRANTED) {
          fbsdkInit(true);
        } else {
          fbsdkInit(false);
        }
      }
    } catch (error) {
      fbsdkInit(false);
    }
  } else if (ATT_CHECK === RESULTS.GRANTED) {
    fbsdkInit(true);
  } else {
    fbsdkInit(false);
  }
}

componentDidMount() {
  if (Platform.OS === "ios" && Number(Platform.Version) > 14.4) {
    getATTPermissionForFbAppEvents();
  } else {
    fbsdkInit(true);
  }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source