Hi,
I will try to do my best but this issue is pretty weird but yet, REALLY important. It's related to https://github.com/RevenueCat/react-native-purchases/issues/777 and https://github.com/RevenueCat/react-native-purchases/issues/627
Sometimes, for a reason I don't understand, the `login` and `setEmail`/`setPhoneNumber`/`setUserName` functions seem doing nothing. This results in unidentified users that have subscriptions not linked to our backend because the `app_user_id` will be the anonymous one and not the custom one we are using.
Then, when the app is killed and opened again, the functions will work correctly (sometimes yes, sometimes no).
My login function is pretty simple :
const login = async (token) => {
updateAuthToken(token);
await storeAuthCookie(token);
const user = await fetchUser();
await Purchases.logIn(user.id.toString());
await Purchases.setEmail(user.email);
await Purchases.setPhoneNumber(user.principalPhone);
await Purchases.setDisplayName(`${user.firstName} ${user.lastName}`);
}
When the app is launched, this `useEffect` is called :
useEffect(() => {
Purchases.setLogLevel(Purchases.LOG_LEVEL.DEBUG);
if (Platform.OS === "ios") {
Purchases.configure({ apiKey: Constants.expoConfig.extra.revenueCatIosApiKey });
} else if (Platform.OS === "android") {
Purchases.configure({ apiKey: Constants.expoConfig.extra.revenueCatAndroidApiKey });
}
}, ]);
That's it. Nothing special, the paywall are working correctly, the app is already in production and I have 0 errors or warnings. But as I said, for 1 on 10 users, I will see in RevenueCat dashboard that they have an active subscription without our custom `userId` and without the `email`, `phoneNumber` and `username` specified. It literally means that we are losing subscriptions and subscribers.
1. Platform: iOS/Android
2. SDK version: 8.6.1
3. OS version: 18.1.3
4. Xcode/Android Studio version: Expo SDK 52
5. React Native version: 0.76.7
6. SDK installation (CocoaPods + version or manual): Expo SDK 52
7. How widespread is the issue. Percentage of devices affected. 10%