Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchDeferredAppLink() returns undefined #594

Open
osafahmad opened this issue Jan 7, 2025 · 0 comments
Open

fetchDeferredAppLink() returns undefined #594

osafahmad opened this issue Jan 7, 2025 · 0 comments

Comments

@osafahmad
Copy link

Issue Summary:
Hi,

We are experiencing the same issue and have searched online for solutions. We've tried various fixes, but we still haven’t received the link from the App Store. It works perfectly on Android via the Play Store but not on iOS.

Our Setup:
React: 18.2.0
React Native: 0.71.8
react-native-fbsdk-next: ^13.3.0
FBSDK iOS Library Version: 17.0 (latest version)
What We've Tried:
We set up the App Tracking Transparency (ATE) permission popup and allowed tracking.
Tested deep link functionality via the Test Deep Link option in the Facebook campaign.
Verified the notification is received using the Facebook App Ads Helper.
However, we are unable to retrieve campaign data from iOS. Below is the testing code we are using:

useEffect(() => {
const handleDeepLink = ({ url }: { url: string }) => {
console.log("URL:==> ", url);
if (url) {
dispatch(onMetaDeepLink(url));
}
};

const requestPermission = async () => {
const status = await requestTrackingPermission();
if (status === 'authorized') {
console.log('User granted permission for tracking');
await Settings.setAdvertiserTrackingEnabled(true);
await Settings.initializeSDK();
handleInitialURL();
} else if (status === 'denied') {
console.log('User denied permission for tracking');
} else if (status === 'not-determined') {
console.log('User has not yet made a decision');
}
};

const handleInitialURL = async () => {
try {
const isFirstLaunch = await AsyncStorage.getItem('isFirstLaunch');
if (isFirstLaunch === null || isFirstLaunch === undefined) {
await AsyncStorage.setItem('isFirstLaunch', 'false');
const deferredUrl = await AppLink.fetchDeferredAppLink();
Alert.alert(JSON.stringify(deferredUrl));
if (deferredUrl) {
handleDeepLink({ url: deferredUrl });
}
} else {
console.log("Second Launch");
const initialUrl = await Linking.getInitialURL();
console.log("Initial URL: ", initialUrl);
if (initialUrl) {
handleDeepLink({ url: initialUrl });
}
}
} catch (error) {
console.error("Error fetching initial/deferred URL:", error);
}
};

if (Platform.OS === 'ios') {
const majorVersionIOS = DeviceInfo.getSystemVersion();
console.log("iOS Version: ", majorVersionIOS);
const majorVersion = parseFloat(majorVersionIOS.split('.')[0]);
if (majorVersion >= 14) {
console.log("Check Worked");
requestPermission();
} else {
Settings.setAdvertiserTrackingEnabled(true);
Settings.initializeSDK();
handleInitialURL();
}
}

const subscription = Linking.addEventListener('url', handleDeepLink);
return () => {
subscription.remove();
};
}, [dispatch, onMetaDeepLink]);

Request:
We would appreciate any guidance or insights on how to resolve this issue and retrieve campaign data from iOS. Any help would be greatly valued!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant