Skip to content

Commit

Permalink
Merge pull request #323 from qonversion/release/8.1.2
Browse files Browse the repository at this point in the history
Release 8.1.2
  • Loading branch information
SpertsyanKM committed Sep 4, 2024
2 parents cfff240 + ad82fd2 commit e80a4ca
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
32 changes: 30 additions & 2 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type StateType = {
subscriptionButtonTitle: string;
loading: boolean;
checkEntitlementsHidden: boolean;
subscriptionProduct: Product | null,
inAppProduct: Product | null,
};

const InAppProductId = 'in_app';
Expand All @@ -41,6 +43,8 @@ export class QonversionSample extends React.PureComponent<{}, StateType> {
subscriptionButtonTitle: 'Loading...',
loading: true,
checkEntitlementsHidden: true,
subscriptionProduct: null,
inAppProduct: null,
};

// eslint-disable-next-line consistent-this
Expand Down Expand Up @@ -115,6 +119,8 @@ export class QonversionSample extends React.PureComponent<{}, StateType> {
inAppButtonTitle: inAppTitle,
subscriptionButtonTitle: subscriptionButtonTitle,
checkEntitlementsHidden: checkActiveEntitlementsButtonHidden,
subscriptionProduct: subscription,
inAppProduct: inApp,
});
});
}
Expand Down Expand Up @@ -147,8 +153,19 @@ export class QonversionSample extends React.PureComponent<{}, StateType> {
<TouchableOpacity
style={styles.subscriptionButton}
onPress={() => {
if (!this.state.subscriptionProduct) {
Alert.alert(
'Error',
'Purchasing product not found - id ' + SubscriptionProductId,
[
{text: 'OK'},
],
{cancelable: true}
);
return;
}
this.setState({loading: true});
Qonversion.getSharedInstance().purchase(new PurchaseModel(SubscriptionProductId)).then(() => {
Qonversion.getSharedInstance().purchaseProduct(this.state.subscriptionProduct).then(() => {
this.setState({loading: false, subscriptionButtonTitle: 'Purchased'});
}).catch(error => {
this.setState({loading: false});
Expand All @@ -171,8 +188,19 @@ export class QonversionSample extends React.PureComponent<{}, StateType> {
<TouchableOpacity
style={styles.inAppButton}
onPress={() => {
if (!this.state.inAppProduct) {
Alert.alert(
'Error',
'Purchasing product not found - id ' + InAppProductId,
[
{text: 'OK'},
],
{cancelable: true}
);
return;
}
this.setState({loading: true});
Qonversion.getSharedInstance().purchase(new PurchaseModel(InAppProductId)).then(() => {
Qonversion.getSharedInstance().purchaseProduct(this.state.inAppProduct).then(() => {
this.setState({loading: false, inAppButtonTitle: 'Purchased'});
}).catch(error => {
this.setState({loading: false});
Expand Down
12 changes: 6 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ PODS:
- Qonversion (5.12.0):
- Qonversion/Main (= 5.12.0)
- Qonversion/Main (5.12.0)
- QonversionSandwich (5.1.1):
- QonversionSandwich (5.1.3):
- Qonversion (= 5.12.0)
- RCT-Folly (2021.07.22.00):
- boost
Expand Down Expand Up @@ -289,8 +289,8 @@ PODS:
- React-jsinspector (0.70.7)
- React-logger (0.70.7):
- glog
- react-native-qonversion (8.0.1):
- QonversionSandwich (= 5.1.1)
- react-native-qonversion (8.1.1):
- QonversionSandwich (= 5.1.3)
- React
- React-perflogger (0.70.7)
- React-RCTActionSheet (0.70.7):
Expand Down Expand Up @@ -536,7 +536,7 @@ SPEC CHECKSUMS:
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
Qonversion: ac2da69e497cb1f01cea13d82513fde14f338ca3
QonversionSandwich: 0fc30a920cfed34238bdb6830b6ca6388294107c
QonversionSandwich: 17c9b9db0af4f7810b2c57c8ca90c838c487ebf7
RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda
RCTRequired: 837880d26ec119e105317dc28a456f3016bf16d1
RCTTypeSafety: 5c854c04c3383cab04f404e25d408ed52124b300
Expand All @@ -551,7 +551,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: e95cdd036e7947ddf87f3049319ac3064deb76b5
React-jsinspector: 1c34fea1868136ecde647bc11fae9266d4143693
React-logger: e9f407f9fdf3f3ce7749ae6f88affe63e8446019
react-native-qonversion: 0fa511df2132c06ba0cbe0f5764124c97074cd99
react-native-qonversion: 9433d0c60eadc033e2f55efcc68bad34112a82ec
React-perflogger: 52a94f38c19a518d05726624b49bfc192639374d
React-RCTActionSheet: 7b89fe64a852bc3ae39b91dbd142ef09931ef3f7
React-RCTAnimation: ad84bfbf8c5f6f77e65092d0c2b0506b80b5cf99
Expand All @@ -571,4 +571,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: f9772353ed0452b7cd7aaeb49261dbd07dd4af10

COCOAPODS: 1.15.2
COCOAPODS: 1.13.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-native-qonversion",
"title": "React Native Qonversion",
"version": "8.1.1",
"version": "8.1.2",
"description": "Qonversion provides full in-app purchases infrastructure, so you do not need to build your own server for receipt validation. Implement in-app subscriptions, validate user receipts, check subscription status, and provide access to your app features and content using our StoreKit wrapper and Google Play Billing wrapper.",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/QonversionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface QonversionApi {
*
* @see [Making Purchases](https://documentation.qonversion.io/docs/making-purchases)
*/
purchaseProduct(product: Product, options: PurchaseOptions): Promise<Map<string, Entitlement>>
purchaseProduct(product: Product, options: PurchaseOptions | undefined): Promise<Map<string, Entitlement>>

/**
* Make a purchase and validate it through server-to-server using Qonversion's Backend.
Expand Down
8 changes: 6 additions & 2 deletions src/internal/QonversionInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import PurchaseOptionsBuilder from "../dto/PurchaseOptionsBuilder";

const {RNQonversion} = NativeModules;

const sdkVersion = "8.1.1";
const sdkVersion = "8.1.2";

const EVENT_ENTITLEMENTS_UPDATED = "entitlements_updated";
const EVENT_PROMO_PURCHASE_RECEIVED = "promo_purchase_received";
Expand Down Expand Up @@ -60,8 +60,12 @@ export default class QonversionInternal implements QonversionApi {
return isAccessibleResult.success;
}

async purchaseProduct(product: Product, options: PurchaseOptions): Promise<Map<string, Entitlement>> {
async purchaseProduct(product: Product, options: PurchaseOptions | undefined): Promise<Map<string, Entitlement>> {
try {
if (!options) {
options = new PurchaseOptionsBuilder().build();
}

let purchasePromise: Promise<Record<string, QEntitlement> | null | undefined>;
if (isIos()) {
purchasePromise = RNQonversion.purchase(product.qonversionID, options.quantity, options.contextKeys);
Expand Down

0 comments on commit e80a4ca

Please sign in to comment.