I am working on retrieving the FCM token and my implementation works perfectly on iOS 17. However, when I try the same code on iOS 15, I consistently receive a null value for the device token. Below is the relevant portion of my code. Do I need to change my implementation for lower iOS versions? It feels like this might be related to the App Tracking Transparency (ATT) permission. Any insights on why this might be happening or how to resolve it would be greatly appreciated.
const userlogin = async () => {
const deviceType = Platform.OS == 'ios' ? 'IOS' : 'ANDROID';
try {
let fcmToken = await AsyncStorage.getItem('fcmToken');
if (!EMAIL_REGEX.test(email)) {
showError('Please enter email');
updateState({isloading: false});
} else if (password?.length < 4) {
if (password?.length < 1) {
showError('Please enter password');
updateState({isloading: false});
} else {
showError('Password should be at least 6 characters long');
updateState({isloading: false});
}
} else {
let apidata = {
email: email?.toLowerCase(),
password: password,
deviceToken: fcmToken,
deviceType: deviceType,
};
actions
.Userlogin(apidata)
.then((res: any) => {
if (!res?.isProfileSetup && res?.tagsId?.length > 0) {
navigation.navigate(navigationString.PRESONALIZESCREEN, {
userData: res,
});
updateState({isloading: false});
} else if (
(!res?.isProfileSetup && res?.tagsId?.length == 0) ||
res?.tagsId?.length == undefined
) {
navigation.navigate(navigationString.HOBBIESSCREEN);
updateState({isloading: false});
} else {
updateState({isloading: false});
// showSuccess('Welcome!');
}
console.log(res, 'User has successfully logged in');
})
.catch((err: any) => {
!!err?.data && showError(err?.data);
updateState({isloading: false});
});
}
} catch {
updateState({isloading: false});
}
};