Reputation: 8707
Hi I tried everything to query/retrieve subscriptions with Flutter using the official in_app_purchase
package but I don't get them.
Everything works fine with iOS. With the same code on Android, it doesn't work.
This is what I get in the console
Purchase etf_info_access_subscription not found
class IAPConnection {
static InAppPurchase? _instance;
static set instance(InAppPurchase value) {
_instance = value;
}
static InAppPurchase get instance {
_instance ??= InAppPurchase.instance;
return _instance!;
}
}
class SubscriptionsProvider extends ChangeNotifier {
List<PurchasableProduct> products = [];
List<PastPurchase> purchases = [];
StoreState storeState = StoreState.loading;
final iapConnection = IAPConnection.instance;
SubscriptionsProvider() {
loadPurchases();
}
Future<void> loadPurchases() async {
final available = await iapConnection.isAvailable();
if (!available) {
storeState = StoreState.notAvailable;
notifyListeners();
return;
}
final serverAvailable =
// ignore: use_build_context_synchronously
await NetworkService.instance.testServerAvailability();
if (serverAvailable == false) {
storeState = StoreState.notAvailable;
notifyListeners();
return;
}
const ids = <String>{storeKeySubscription}; // which is 'etf_info_access_subscription'
final response = await iapConnection.queryProductDetails(ids);
for (var element in response.notFoundIDs) {
debugPrint('Purchase $element not found'); // I always get this printed in Android :(
}
products =
response.productDetails.map((e) => PurchasableProduct(e)).toList();
debugPrint(products.toString()); // Always empty
storeState = StoreState.available;
notifyListeners();
}
}
These are the dependencies in /app/build.gradle
def billing_version = "5.0.0"
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation("com.android.billingclient:billing:$billing_version")
}
My AndroidManifest.xml permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.vending.BILLING" />
I also uploaded a build with these onto the play store closed and internal testing successfully but still I can't retrieve products...
I have also created a subscription with the same ID as the app:
Upvotes: 3
Views: 2627
Reputation: 5169
There are a few things that can cause this so hard to say exactly but the first things to check are that:
There is a helpful article here screenshots and other reasons why this can happen on iOS and Android: https://community.revenuecat.com/sdks-51/why-are-offerings-or-products-empty-124
Upvotes: 3