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

Android/iOS - login and setEmail/setPhoneNumber/setUserName functions are sometimes not working #1198

Open
4 tasks done
yonitou opened this issue Feb 26, 2025 · 3 comments
Open
4 tasks done
Labels
bug Something isn't working

Comments

@yonitou
Copy link

yonitou commented Feb 26, 2025

I will try to do my best but this issue is pretty weird but yet, REALLY important. It's related to #777 and #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.

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%
@yonitou yonitou added the bug Something isn't working label Feb 26, 2025
@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@nyeu
Copy link

nyeu commented Feb 28, 2025

Hi @yonitou,
Do you have Track new purchases from server-to-server notifications marked in your project? If so, it could happen that sometimes we register purchases before the SDK had the option to send the email and id values. It's also worth checking if you are force sending the attributes to make sure they are in our system as soon as possible using syncAttributesAndOfferingsIfNeeded.

@yonitou
Copy link
Author

yonitou commented Feb 28, 2025

Hi @nyeu ,

Thanks for your quick answer. Yes, of course, Track new purchases from server-to-server notifications is on

Image

I'm not using syncAttributesAndOfferingsIfNeeded function. Where and when should I call it ? How would I know if that would be enough to send them ?
For me, the issue is that the login and setXXX functions must throw error if the attributes are not sent to RC backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants