flutter_iap
flutter_iap copied to clipboard
Issue restoring purchases on iOS
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");
});
},
),
),
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.
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?
Could you try this with version 2.0.0-pre1?