-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Description
Steps to Reproduce
- Install
in_app_purchase
: https://pub.dev/packages/in_app_purchase#restoring-previous-purchases - Configure to work on iOS
- Try to get past purchases
Expected results:
I should my past purchases
Actual results:
I don't get any purchases on iOS (Android works fine)
More info:
I had already this plugin working perfectly on both platforms but I updated it to latest version facing all the breaking changes (so all products are setup ok and already have user on both platforms that bought my app). The documentation is not helping much because I read different steps/code:
if (defaultTargetPlatform == TargetPlatform.android) {
InAppPurchaseAndroidPlatformAddition.enablePendingPurchases();
}
runApp(MyApp());
That's what I read here: https://pub.dev/packages/in_app_purchase but if I go to https://codelabs.developers.google.com/codelabs/flutter-in-app-purchases#5 (also linked from previous page) we don't have the check for Android:
InAppPurchaseAndroidPlatformAddition.enablePendingPurchases();
runApp(MyApp());
This is my code already working for Android:
final Stream<List<PurchaseDetails>> purchaseUpdated =
inAppPurchase.purchaseStream;
_subscription = purchaseUpdated.listen((purchaseDetailsList) {
if (purchaseDetailsList.isEmpty) {
Provider.of<AdState>(context, listen: false).toggleAds(context, true);
} else {
Provider.of<AdState>(context, listen: false)
.toggleAds(context, false);
this.purchases.addAll(purchaseDetailsList);
listenToPurchaseUpdated(purchaseDetailsList);
}
}, onDone: () {
_subscription.cancel();
}, onError: (error) {
// handle error here.
});
inAppPurchase.restorePurchases();
I can add _inAppPurchase.completePurchase(purchase);
or:
Map<String, PurchaseDetails> purchases =
Map.fromEntries(this.purchases.map((PurchaseDetails purchase) {
if (purchase.pendingCompletePurchase) {
inAppPurchase.completePurchase(purchase);
}
return MapEntry<String, PurchaseDetails>(
purchase.productID, purchase);
}));
but that doesn't solve anything because this.purchases
still empty since we are not going inside the first listen
and the list of purchases still empty.
dani@DanielRodriguezs-MacBook-Pro my_rents % flutter analyze
The plugins `flutter_statusbarcolor_ns, libphonenumber` use a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove
these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Analyzing my_rents...
info • The value of the local variable 'daysFromTodayToEndDate' isn't used • lib/helpers/helpers.dart:429:9 • unused_local_variable
info • The value of the local variable 'daysFromTodayToStartDate' isn't used • lib/helpers/helpers.dart:430:9 • unused_local_variable
info • The value of the local variable 'locale' isn't used • lib/helpers/helpers.dart:532:12 • unused_local_variable
info • Unused import: 'dart:io' • lib/main.dart:4:8 • unused_import
info • 'buttonColor' is deprecated and shouldn't be used. No longer used by the framework, please remove any reference to it. This feature was deprecated after v2.3.0-0.2.pre. • lib/main.dart:122:11 •
deprecated_member_use
info • The operand can't be null, so the condition is always true • lib/models/invoice.dart:22:29 • unnecessary_null_comparison
info • The value of the field '_numInterstitialLoadAttempts' isn't used • lib/providers/ad_state.dart:36:7 • unused_field
info • The value of the field '_loadingBannerAd' isn't used • lib/providers/ad_state.dart:170:8 • unused_field
info • 'showSnackBar' is deprecated and shouldn't be used. Use ScaffoldMessenger.showSnackBar. This feature was deprecated after v1.23.0-14.0.pre. • lib/screens/Invoices/invoice_details.dart:33:36 •
deprecated_member_use
info • 'showSnackBar' is deprecated and shouldn't be used. Use ScaffoldMessenger.showSnackBar. This feature was deprecated after v1.23.0-14.0.pre. • lib/screens/Invoices/my_invoice.dart:457:43 •
deprecated_member_use
info • The operand can't be null, so the condition is always true • lib/screens/Invoices/taxes_withholdings.dart:133:46 • unnecessary_null_comparison
info • The operand can't be null, so the condition is always true • lib/screens/Invoices/taxes_withholdings.dart:185:44 • unnecessary_null_comparison
info • The operand can't be null, so the condition is always true • lib/screens/Invoices/taxes_withholdings.dart:208:22 • unnecessary_null_comparison
info • This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: TaxesWithholdingsGroupsScreen._mainColor •
lib/screens/Invoices/taxes_withholdings_group.dart:14:7 • must_be_immutable
info • The value of the field '_events' isn't used • lib/screens/calendar.dart:17:37 • unused_field
info • The declaration '_fileDownloadProgress' isn't referenced • lib/screens/expense.dart:646:10 • unused_element
info • 'showSnackBar' is deprecated and shouldn't be used. Use ScaffoldMessenger.showSnackBar. This feature was deprecated after v1.23.0-14.0.pre. • lib/screens/lease.dart:356:39 • deprecated_member_use
info • The operand can't be null, so the condition is always true • lib/screens/new_event.dart:227:32 • unnecessary_null_comparison
info • The value of the field '_invoiceFile' isn't used • lib/screens/new_expense.dart:72:9 • unused_field
info • The value of the field '_invoiceUrl' isn't used • lib/screens/new_expense.dart:73:11 • unused_field
info • 'showSnackBar' is deprecated and shouldn't be used. Use ScaffoldMessenger.showSnackBar. This feature was deprecated after v1.23.0-14.0.pre. • lib/screens/new_expense.dart:736:41 •
deprecated_member_use
info • The declaration '_total' isn't referenced • lib/screens/new_expense.dart:755:10 • unused_element
info • The declaration '_buildCurrencyDialogItem' isn't referenced • lib/screens/options.dart:247:10 • unused_element
info • The declaration '_generateBorderRadius' isn't referenced • lib/screens/portfolio_info.dart:778:3 • unused_element
info • The declaration '_statOptions' isn't referenced • lib/screens/portfolio_info.dart:787:3 • unused_element
info • The value of the field '_selectedEvents' isn't used • lib/screens/rent.dart:65:22 • unused_field
info • The value of the field '_isLoading' isn't used • lib/screens/rent.dart:73:13 • unused_field
info • The declaration '_pickImageOptions' isn't referenced • lib/screens/rent.dart:691:3 • unused_element
info • 'getImage' is deprecated and shouldn't be used. Switch to using pickImage instead • lib/screens/rent.dart:761:42 • deprecated_member_use
info • The declaration '_showPaymentConfirmation' isn't referenced • lib/screens/rent.dart:1110:10 • unused_element
info • The declaration '_calendarActions' isn't referenced • lib/screens/rent.dart:1246:10 • unused_element
info • 'showSnackBar' is deprecated and shouldn't be used. Use ScaffoldMessenger.showSnackBar. This feature was deprecated after v1.23.0-14.0.pre. • lib/screens/rent.dart:1269:39 • deprecated_member_use
info • The value of the local variable 'createPaymentDayEventCopy' isn't used • lib/screens/rent.dart:1290:21 • unused_local_variable
info • The declaration '_fileDownloadProgress' isn't referenced • lib/screens/rent.dart:2125:10 • unused_element
info • 'showSnackBar' is deprecated and shouldn't be used. Use ScaffoldMessenger.showSnackBar. This feature was deprecated after v1.23.0-14.0.pre. • lib/screens/rent.dart:2335:45 • deprecated_member_use
info • The declaration '_stopLease' isn't referenced • lib/screens/rent.dart:2592:10 • unused_element
info • The declaration '_deleteDocument' isn't referenced • lib/screens/rent.dart:2753:3 • unused_element
info • The operand can't be null, so the condition is always true • lib/screens/rent.dart:2856:11 • unnecessary_null_comparison
info • 'showSnackBar' is deprecated and shouldn't be used. Use ScaffoldMessenger.showSnackBar. This feature was deprecated after v1.23.0-14.0.pre. • lib/screens/rent.dart:2863:16 • deprecated_member_use
info • Equality operator `==` invocation with references of unrelated types • lib/screens/rent.dart:2934:25 • unrelated_type_equality_checks
info • The declaration '_buildActionForTask' isn't referenced • lib/screens/rent.dart:2957:10 • unused_element
info • The value of the field '_events' isn't used • lib/screens/table_events.dart:57:37 • unused_field
info • The value of the local variable 'snackBar' isn't used • lib/screens/table_events.dart:380:31 • unused_local_variable
info • Cancel instances of dart.async.StreamSubscription • lib/screens/versions.dart:25:23 • cancel_subscriptions
info • 'FlatButton' is deprecated and shouldn't be used. Use TextButton instead. See the migration guide in flutter.dev/go/material-button-migration-guide). This feature was deprecated after
v1.26.0-18.0.pre. • lib/screens/versions.dart:341:12 • deprecated_member_use
info • The value of the local variable 'user' isn't used • lib/services/auth.dart:39:18 • unused_local_variable
info • The value of the local variable 'user' isn't used • lib/services/auth.dart:64:18 • unused_local_variable
info • The operand can't be null, so the condition is always true • lib/services/create_invoice_pdf.dart:160:18 • unnecessary_null_comparison
info • The operand can't be null, so the condition is always true • lib/services/create_invoice_pdf.dart:161:18 • unnecessary_null_comparison
info • The operand can't be null, so the condition is always true • lib/services/create_invoice_pdf.dart:162:18 • unnecessary_null_comparison
info • The declaration '_formatDate' isn't referenced • lib/services/create_invoice_pdf.dart:659:8 • unused_element
info • Avoid empty statements • lib/services/firebase_profile.dart:337:9 • empty_statements
info • 'showSnackBar' is deprecated and shouldn't be used. Use ScaffoldMessenger.showSnackBar. This feature was deprecated after v1.23.0-14.0.pre. • lib/services/phone_contact.dart:49:28 •
deprecated_member_use
info • The declaration '_showError' isn't referenced • lib/services/phone_contact.dart:53:3 • unused_element
info • 'showSnackBar' is deprecated and shouldn't be used. Use ScaffoldMessenger.showSnackBar. This feature was deprecated after v1.23.0-14.0.pre. • lib/services/phone_contact.dart:57:26 •
deprecated_member_use
info • 'getImage' is deprecated and shouldn't be used. Switch to using pickImage instead • lib/services/select_documents.dart:101:42 • deprecated_member_use
info • The value of the local variable '_timer' isn't used • lib/widgets/important_message.dart:9:11 • unused_local_variable
info • 'showSnackBar' is deprecated and shouldn't be used. Use ScaffoldMessenger.showSnackBar. This feature was deprecated after v1.23.0-14.0.pre. • lib/widgets/important_message.dart:21:25 •
deprecated_member_use
info • This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: MySwitch.param, MySwitch.callback • lib/widgets/my_switch.dart:4:7
• must_be_immutable
info • The operand can't be null, so the condition is always true • lib/widgets/phone_number_selector.dart:42:49 • unnecessary_null_comparison
info • The value of the local variable 'deletedPortfolio' isn't used • lib/widgets/portfolio_options.dart:40:23 • unused_local_variable
info • This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: Rents.portfolio • lib/widgets/rents.dart:21:7 • must_be_immutable
info • Name types using UpperCamelCase • lib/widgets/taxes_groups_dropdown.dart:134:9 • camel_case_types
63 issues found. (ran in 24.5s)
flutter doctor -v
[✓] Flutter (Channel stable, 2.5.0, on macOS 11.5.2 20G95 darwin-x64, locale en-GB)
• Flutter version 2.5.0 at /Users/dani/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4cc385b4b8 (5 days ago), 2021-09-07 23:01:49 -0700
• Engine revision f0826da7ef
• Dart version 2.14.0
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/dani/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] VS Code (version 1.60.0)
• VS Code at /Users/dani/Desktop/Visual Studio Code.app/Contents
• Flutter extension version 3.26.0
[✓] Connected device (2 available)
• iPhone 11 Pro Max (mobile) • 71D058B9-0AC2-4EFB-8F49-F9ADB8B78F13 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.63
• No issues found!