hyochan / flutter_inapp_purchase

(Sun Rised!) Flutter plugin for In App Purchase.
MIT License
550 stars 235 forks source link

PlatformException(initConnection, responseCode: 3, , null) - Is it client device issue, can we just ignore it ? #378

Closed meomap closed 1 year ago

meomap commented 2 years ago

Version of flutter_inapp_purchase

5.3.1

Platforms you faced the error (IOS or Android or both?)

Android

Expected behavior

No error thrown

Actual behavior

PlatformException(initConnection, responseCode: 3, , null)

Only a small portion of users affected, including google's test devices sdk_goog3_x86_64. So maybe it's an issue of GooglePlayStore settings at client's device ??

Tested environment (Emulator? Real Device?)

Real device - production release

Steps to reproduce the behavior

I can't reproduce yet. It works fine when I used test cards at real device. Some users can make purchase with this version. As I said, It happens occasionally.

Code snippet

  late FlutterInappPurchase _inner;

  StreamSubscription? _purchaseUpdatedSubscription;
  StreamSubscription? _purchaseErrorSubscription;
  StreamSubscription? _connectionSubscription;

  void init() async {
    _inner = FlutterInappPurchase.instance;
    await _inner.initialize();
    subscribe();
    restorePurchases();
    initProduct();
  } 

  void subscribe() {
    _connectionSubscription =
        FlutterInappPurchase.connectionUpdated.listen((connected) {
      print('connected: $connected');
    });

    _purchaseUpdatedSubscription =
        FlutterInappPurchase.purchaseUpdated.listen((item) {
      print('purchase-updated: $item');
    });

    _purchaseErrorSubscription =
        FlutterInappPurchase.purchaseError.listen((purchaseError) {
      print('purchase-error: $purchaseError');
    });
  }

  void restorePurchases() async {
    await _inner.getAvailablePurchases();
  }

  void initProduct() async {
    await _inner.getProducts(productIds);
  }

  @override
  void dispose() {
    _purchaseUpdatedSubscription?.cancel();
    _purchaseErrorSubscription?.cancel();
    _connectionSubscription?.cancel();
    _inner.finalize();
    super.dispose();
  } 
mokhalid1698 commented 2 years ago

Did you find a solution?

meomap commented 2 years ago

@mokhalid1698 My current solution is just ignore it 😅 My assumption is that there's something wrong with their devices. Maybe a bot device, unavailable google play service, side loaded app or unsupported countries. Those users can't make make purchase via google payment anyway.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.

jihchao commented 1 year ago

Did you find a solution?