-
Notifications
You must be signed in to change notification settings - Fork 170
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
Canceling subscription crashes app in production #1207
Comments
👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out! |
Hi, if you just released your app on the App Store, then this could be due to products needing ~24 hours to propagate after release. If it has been longer than that, can you make sure that when your app launches you are calling configure right away? Such errors occur if methods of the SDK are attempting to be accessed without initializing it first. Could you share the following:
|
Hey we have this function to set revenueCat Future<void> configureRevenueCat(String? customerId) async {
if (kIsWeb || customerId == null) {
return;
}
try {
await Purchases.setLogLevel(LogLevel.info);
await Purchases.configure(
PurchasesConfiguration(
Platform.isIOS ? Env.revenueCatAppleApiKey : Env.revenueCatGoogleApiKey,
)..appUserID = customerId,
);
} on Exception catch (e) {
log('Error configuring RevenueCat: $e');
}
}
Future<void> setRevenueCatUser(ConsumerProfileState? profile) async {
try {
if (kIsWeb) {
return;
}
if (profile == null || profile.subscriptionId == null) {
return;
}
await configureRevenueCat(profile.subscriptionId);
await Purchases.logIn(profile.subscriptionId!);
await Purchases.setEmail(profile.email);
await Purchases.setDisplayName('${profile.firstname} ${profile.lastname}');
await Purchases.setPhoneNumber(profile.phoneNumber?.toString() ?? '');
} on Exception catch (e) {
log('Error setting RevenueCat user: $e');
}
} The This is the function that is called when an offering is selected and the users presses the buy button: Future<void> onBuySubscriptionPress() async {
final selectedProduct = offeringResult.products.firstWhereOrNull(
(element) => element.product.identifier == activeSubscriptionId.value,
);
if (selectedProduct == null) {
return;
}
try {
final customerInfo =
await Purchases.purchaseStoreProduct(selectedProduct.product);
if (customerInfo.entitlements.all['recipe-subscription']!.isActive) {
await router.replaceAll([const BuySubscriptionConfirmationRoute()]);
}
} on PlatformException catch (e) {
final errorCode = PurchasesErrorHelper.getErrorCode(e);
if (errorCode != PurchasesErrorCode.purchaseCancelledError) {
showErrorMessage(
scaffoldMessenger,
description: LocaleKeys
.buySubscription_messages_activate_subscription_error
.tr(),
);
}
}
return;
} |
Do not remove any of the steps from the template below. If a step is not applicable to your issue, please leave that step empty.
There are a lot of things that can contribute to things not working. Having a very basic understanding of your environment will help us understand your issue faster!
Environment
flutter doctor
purchases-flutter
8.2.1
iOS 17.7
Only happens in production builds with real subscriptions. On all tested devices.
Never with a sandbox environment.
In a production environment
Load subscriptions in the app
Click on a subscription
Native popup will open
Close subscription popu
App crashes
Describe the bug
The app will crash on iOS when you close the native subscriptions popup of apple. Only in production.
Additional context
The error shows an error that the purchases SDK is not configured. But The subscriptions can be fetched correctly from revenueCat. No issues when doing this in a sandox.
The text was updated successfully, but these errors were encountered: