Skip to content

Commit

Permalink
Merge pull request #353 from qonversion/release/9.1.2
Browse files Browse the repository at this point in the history
Release 9.1.2
  • Loading branch information
SpertsyanKM authored Sep 6, 2024
2 parents a7251db + 5e4f2c5 commit 0b13164
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 9.1.2
* Added ability to call `purchase` without providing any options.

## 9.1.1
* iOS error codes improved

Expand Down
6 changes: 2 additions & 4 deletions example/lib/products_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class _ProductsViewState extends State<ProductsView> {

Future<void> _loadProducts() async {
try {
var mainOffering = _offerings?.offeringForIdentifier("main");
var mainOffering = _offerings?.main;
_products = mainOffering?.products ?? [];
setState(() {});
} catch (e) {
Expand All @@ -135,9 +135,7 @@ class _ProductsViewState extends State<ProductsView> {
),
onPressed: () async {
try {
final purchaseModel = product.toPurchaseModel();
final entitlements =
await Qonversion.getSharedInstance().purchase(purchaseModel);
final entitlements = await Qonversion.getSharedInstance().purchaseProduct(product);
final entitlement = entitlements.values.firstWhereOrNull((element) => element.productId == product.qonversionId);

print(entitlement?.isActive);
Expand Down
8 changes: 6 additions & 2 deletions lib/src/internal/qonversion_internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:qonversion_flutter/src/internal/utils/string.dart';
import 'constants.dart';

class QonversionInternal implements Qonversion {
static const String _sdkVersion = "9.1.1";
static const String _sdkVersion = "9.1.2";

final MethodChannel _channel = MethodChannel('qonversion_plugin');

Expand Down Expand Up @@ -80,8 +80,12 @@ class QonversionInternal implements Qonversion {
}

@override
Future<Map<String, QEntitlement>> purchaseProduct(QProduct product, QPurchaseOptions purchaseOptions) async {
Future<Map<String, QEntitlement>> purchaseProduct(QProduct product, {QPurchaseOptions? purchaseOptions}) async {
try {
if (purchaseOptions == null) {
purchaseOptions = new QPurchaseOptionsBuilder().build();
}

final rawResult = await _channel
.invokeMethod(Constants.mPurchase, {
Constants.kProductId: product.qonversionId,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/qonversion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract class Qonversion {
/// [options] additional options for the purchase process.
/// Returns the promise with the user entitlements including the ones obtained by the purchase.
/// Throws [QPurchaseException] in case of error in purchase flow.
Future<Map<String, QEntitlement>> purchaseProduct(QProduct product, QPurchaseOptions purchaseOptions);
Future<Map<String, QEntitlement>> purchaseProduct(QProduct product, {QPurchaseOptions? purchaseOptions});

/// Android only. Returns `null` if called on iOS.
///
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: qonversion_flutter
description: Flutter plugin to implement in-app subscriptions and purchases. Validate user receipts and manage cross-platform access to paid content on your app. Android & iOS.
version: 9.1.1
version: 9.1.2
homepage: 'https://qonversion.io'
repository: 'https://github.com/qonversion/flutter-sdk'

Expand Down

0 comments on commit 0b13164

Please sign in to comment.