-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
The problem is with this line in in_app_purchase google_play_connection.dart
Future<void> _connect() =>
billingClient.startConnection(onBillingServiceDisconnected: () {});
It does not check the response and there is no way to know that anything or what has gone wrong. The only way to reconnect to BillingClient is when the user exits the app or puts it to background and then opens the app again.
From BillingClient docs, if the response is SERVICE_DISCONNECTED, then a reconnect should be attempted. Im pretty sure there are other responses, that should initiate a recovery.
Some other observations as well:
- The onDisconnect callback is ignored, which would be a good place to initiate recovery.
- Furthermore from docs BillingClientStateListener.onBillingServiceDisconnected implies that onBillingSetupFinished can be called multiple times, which is not supported by InAppPurchasePlugin.java.
These are mostly corner cases, but I think definitely important to solve.
Steps to Reproduce
The easiest way to create an error is:
- Call adb shell pm clear com.android.vending in terminal
- Start app without network.
Now the service should fail and disconnect
or
- Call adb shell pm clear com.android.vending in terminal when the service is already connected.
now the onDisconnect is called (and again ignored) and no reconnect attempt is done.
Logs
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.6 18G87, locale
et-EE)
• Flutter version 1.7.8+hotfix.4 at /Users/siim/Binaries/flutter
• Framework revision 20e59316b8 (7 weeks ago), 2019-07-18 20:04:33 -0700
• Engine revision fee001c93f
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/siim/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /Users/siim/Library/Android/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.3, Build version 10G8
• CocoaPods version 1.6.1
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 38.2.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1343-b01)