flutter_iap icon indicating copy to clipboard operation
flutter_iap copied to clipboard

Issue restoring purchases on iOS

Open ItsCalebJones opened this issue 6 years ago • 2 comments

I see this in the logs when calling the 'restorePurchases' method, seems I never get a response myself.

flutter: Error found type 'int' is not a subtype of type 'Map<String, dynamic>'

Here's my code - from the best I can tell a response is never returned.

new MergeSemantics(
          child: new ListTile(
            title: new Text('Restore Purchases'),
            subtitle: new Text('Click here to restore in app purchases.'),
            onTap: () async {
              FlutterIap.restorePurchases().then((IAPResponse response) {
                print(response);
                String responseStatus = response.status;
                print("Response: $responseStatus");
                if (response.purchases != null) {
                  List<String> purchasedIds = response.purchases
                      .map((IAPPurchase purchase) => purchase.productIdentifier)
                      .toList();
                  if (purchasedIds.length > 0) {
                    sendUpdates(widget.configuration.copyWith(showAds: false));
                    _prefs.then((SharedPreferences prefs) {
                      return (prefs.setBool('showAds', false));
                    });
                  }
                }
                final snackBar = new SnackBar(
                  content: new Text('Purchase history restored: ' + response.status),
                  duration: new Duration(seconds: 5),
                );
                // Find the Scaffold in the Widget tree and use it to show a SnackBar
                Scaffold.of(context).showSnackBar(snackBar);
              }, onError: (error) {
                // errors caught outside the framework
                print("Error found $error");
              });
            },
          ),
        ),

ItsCalebJones avatar Sep 07 '18 23:09 ItsCalebJones

This change is causing the error. I'm getting the same thing.

The strange part is the master branch looks different than what code actually got pulled down for me. I see the below after running flutter packages get and inspect the iOS code. screen shot 2018-12-16 at 11 16 27 pm Note it's returning a list of id's,...not a string like everything else. It blows up here trying to parse something other than a JSON string.

I'm guessing something got published and missed the iOS code changes?

kmcgill88 avatar Dec 17 '18 05:12 kmcgill88

Could you try this with version 2.0.0-pre1?

ened avatar Feb 04 '19 02:02 ened