Reputation: 1
static Future<bool> fetchAndPurchaseLifetimeAccess() async {
try {
// Fetch offerings
Offerings offerings = await Purchases.getOfferings();
Offering? offering = offerings.current;
//Printing offerings
offerings.all.forEach(
(key, value) {
print("Offerings are ; $key : $value");
},
);
// Check if lifetime package is available
if (offering != null && offering.lifetime != null) {
debugPrint('Found Lifetime Offering');
// Purchase the lifetime package
CustomerInfo purchaserInfo =
await Purchases.purchasePackage(offering.lifetime!);
// Check if the entitlement is active
if (purchaserInfo.entitlements.all["zsp2_id"]?.isActive == true) {
debugPrint("Lifetime access granted!");
SharedPreferences prefs = await SharedPreferences.getInstance();
// Save premium info on SharedPref
await prefs.setBool('isPremium', true);
return true;
}
} else {
debugPrint("Lifetime package not available.");
}
} catch (e) {
debugPrint("Error purchasing: $e");
}
return false;
}
flutter: Trying to purchase
flutter: Error purchasing: PlatformException(23, There is an issue with your configuration. Check the underlying error for more details. There's a problem with your configuration. None of the products registered in the RevenueCat dashboard could be fetched from App Store Connect (or the StoreKit Configuration file if one is being used).
flutter: More information: https://rev.cat/why-are-offerings-empty, {readable_error_code: CONFIGURATION_ERROR, underlyingErrorMessage: , message: There is an issue with your configuration. Check the underlying error for more details. There's a problem with your configuration. None of the products registered in the RevenueCat dashboard could be fetched from App Store Connect (or the StoreKit Configuration file if one is being used).
flutter: More information: https://rev.cat/why-are-offerings-empty, code: 23, readableErrorCode: CONFIGURATION_ERROR}, null)
What's wrong here? Revenuecat iOS setup in documentation is little bit confusing.
Upvotes: 0
Views: 66