Skip to content

Commit 0d7a35d

Browse files
authored
Release 7.0.0
Release 7.0.0
2 parents 4d2b4cc + 484ef85 commit 0d7a35d

22 files changed

Lines changed: 1126 additions & 271 deletions

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ repositories {
6565
dependencies {
6666
//noinspection GradleDynamicVersion
6767
implementation 'com.facebook.react:react-native:+' // From node_modules
68-
implementation "io.qonversion.sandwich:sandwich:3.3.3"
68+
implementation "io.qonversion.sandwich:sandwich:4.0.0"
6969
}
7070

7171
afterEvaluate { project ->

android/src/main/java/com/reactlibrary/QonversionModule.java

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -84,52 +84,29 @@ public void syncHistoricalData() {
8484
}
8585

8686
@ReactMethod
87-
public void purchaseProduct(String productId, String offeringId, final Promise promise) {
88-
qonversionSandwich.purchaseProduct(productId, offeringId, getPurchaseResultListener(promise));
87+
public void purchase(String productId, @Nullable String offerId, @Nullable Boolean applyOffer, final Promise promise) {
88+
qonversionSandwich.purchase(productId, offerId, applyOffer, getPurchaseResultListener(promise));
8989
}
9090

9191
@ReactMethod
92-
public void purchase(String productId, final Promise promise) {
93-
qonversionSandwich.purchase(productId, getPurchaseResultListener(promise));
94-
}
95-
96-
@ReactMethod
97-
public void updateProductWithId(
98-
final String productId,
99-
@Nullable final String offeringId,
100-
final String oldProductId,
101-
final Promise promise
102-
) {
103-
updateProductWithIdAndProrationMode(productId, offeringId, oldProductId, null, promise);
104-
}
105-
106-
@ReactMethod
107-
public void updateProductWithIdAndProrationMode(
108-
final String productId,
109-
@Nullable final String offeringId,
110-
final String oldProductId,
111-
@Nullable final Integer prorationMode,
92+
public void updatePurchase(
93+
String productId,
94+
@Nullable String offerId,
95+
@Nullable Boolean applyOffer,
96+
String oldProductId,
97+
@Nullable String updatePolicyKey,
11298
final Promise promise
11399
) {
114-
qonversionSandwich.updatePurchaseWithProduct(
100+
qonversionSandwich.updatePurchase(
115101
productId,
116-
offeringId,
102+
offerId,
103+
applyOffer,
117104
oldProductId,
118-
prorationMode,
105+
updatePolicyKey,
119106
getPurchaseResultListener(promise)
120107
);
121108
}
122109

123-
@ReactMethod
124-
public void updatePurchase(String productId, String oldProductId, final Promise promise) {
125-
updatePurchaseWithProrationMode(productId, oldProductId, null, promise);
126-
}
127-
128-
@ReactMethod
129-
public void updatePurchaseWithProrationMode(String productId, String oldProductId, Integer prorationMode, final Promise promise) {
130-
qonversionSandwich.updatePurchase(productId, oldProductId, prorationMode, getPurchaseResultListener(promise));
131-
}
132-
133110
@ReactMethod
134111
public void setDefinedProperty(String key, String value) {
135112
qonversionSandwich.setDefinedProperty(key, value);

example/App.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Qonversion, {
1616
Environment,
1717
Entitlement,
1818
EntitlementsCacheLifetime,
19+
PurchaseModel,
1920
} from 'react-native-qonversion';
2021
import NotificationsManager from './notificationsManager';
2122

@@ -28,14 +29,8 @@ type StateType = {
2829
checkEntitlementsHidden: boolean;
2930
};
3031

31-
const prettyDuration = {
32-
'WEEKLY': 'weekly',
33-
'MONTHLY': 'monthly',
34-
'3_MONTHS': '3 months',
35-
'6_MONTHS': '6 months',
36-
'ANNUAL': 'annual',
37-
'LIFETIME': 'lifetime',
38-
};
32+
const InAppProductId = 'in_app';
33+
const SubscriptionProductId = 'weekly';
3934

4035
export class QonversionSample extends React.PureComponent<{}, StateType> {
4136
constructor(props) {
@@ -90,18 +85,25 @@ export class QonversionSample extends React.PureComponent<{}, StateType> {
9085
let inAppTitle = this.state.inAppButtonTitle;
9186
let subscriptionButtonTitle = this.state.subscriptionButtonTitle;
9287

93-
const inApp: Product = products.get('in_app');
88+
const inApp: Product = products.get(InAppProductId);
9489
if (inApp) {
9590
inAppTitle = 'Buy for ' + inApp.prettyPrice;
91+
9692
const entitlement = entitlements.get('Test Entitlement');
9793
if (entitlement) {
9894
inAppTitle = entitlement.isActive ? 'Purchased' : inAppTitle;
9995
}
10096
}
10197

102-
const main: Product = products.get('weekly');
103-
if (main) {
104-
subscriptionButtonTitle = 'Subscribe for ' + main.prettyPrice + ' / ' + prettyDuration[main.duration];
98+
const subscription: Product = products.get(SubscriptionProductId);
99+
if (subscription) {
100+
subscriptionButtonTitle = 'Subscribe for '
101+
+ subscription.prettyPrice
102+
+ ' / '
103+
+ subscription.subscriptionPeriod.unitCount
104+
+ ' '
105+
+ subscription.subscriptionPeriod.unit;
106+
105107
const entitlement = entitlements.get('plus');
106108
if (entitlement) {
107109
subscriptionButtonTitle = entitlement.isActive ? 'Purchased' : subscriptionButtonTitle;
@@ -146,7 +148,7 @@ export class QonversionSample extends React.PureComponent<{}, StateType> {
146148
style={styles.subscriptionButton}
147149
onPress={() => {
148150
this.setState({loading: true});
149-
Qonversion.getSharedInstance().purchase('weekly').then(() => {
151+
Qonversion.getSharedInstance().purchase(new PurchaseModel(SubscriptionProductId)).then(() => {
150152
this.setState({loading: false, subscriptionButtonTitle: 'Purchased'});
151153
}).catch(error => {
152154
this.setState({loading: false});
@@ -170,7 +172,7 @@ export class QonversionSample extends React.PureComponent<{}, StateType> {
170172
style={styles.inAppButton}
171173
onPress={() => {
172174
this.setState({loading: true});
173-
Qonversion.getSharedInstance().purchase('in_app').then(() => {
175+
Qonversion.getSharedInstance().purchase(new PurchaseModel(InAppProductId)).then(() => {
174176
this.setState({loading: false, inAppButtonTitle: 'Purchased'});
175177
}).catch(error => {
176178
this.setState({loading: false});

example/ios/Podfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ PODS:
7878
- Qonversion (5.5.2):
7979
- Qonversion/Main (= 5.5.2)
8080
- Qonversion/Main (5.5.2)
81-
- QonversionSandwich (3.3.1):
81+
- QonversionSandwich (4.0.0):
8282
- Qonversion (= 5.5.2)
8383
- RCT-Folly (2021.07.22.00):
8484
- boost
@@ -289,8 +289,8 @@ PODS:
289289
- React-jsinspector (0.70.5)
290290
- React-logger (0.70.5):
291291
- glog
292-
- react-native-qonversion (6.2.0):
293-
- QonversionSandwich (= 3.3.1)
292+
- react-native-qonversion (6.3.1):
293+
- QonversionSandwich (= 4.0.0)
294294
- React
295295
- React-perflogger (0.70.5)
296296
- React-RCTActionSheet (0.70.5):
@@ -535,7 +535,7 @@ SPEC CHECKSUMS:
535535
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
536536
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
537537
Qonversion: 290d69d209f83a1defa914912a83fc8897a4af34
538-
QonversionSandwich: a8339feabb3302d6b2dfe9a21372906cfccd507a
538+
QonversionSandwich: 6c377e9f302673eeb22813c5bcc3be70ead9a491
539539
RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda
540540
RCTRequired: 21229f84411088e5d8538f21212de49e46cc83e2
541541
RCTTypeSafety: 62eed57a32924b09edaaf170a548d1fc96223086
@@ -550,7 +550,7 @@ SPEC CHECKSUMS:
550550
React-jsiexecutor: 31564fa6912459921568e8b0e49024285a4d584b
551551
React-jsinspector: badd81696361249893a80477983e697aab3c1a34
552552
React-logger: fdda34dd285bdb0232e059b19d9606fa0ec3bb9c
553-
react-native-qonversion: 83b17ba32811c66dc8bf1182b3fe782f4ab22fa6
553+
react-native-qonversion: a070dfd191b0c52b459970e1c7b6e14d4fe7e03c
554554
React-perflogger: e68d3795cf5d247a0379735cbac7309adf2fb931
555555
React-RCTActionSheet: 05452c3b281edb27850253db13ecd4c5a65bc247
556556
React-RCTAnimation: 578eebac706428e68466118e84aeacf3a282b4da
@@ -570,4 +570,4 @@ SPEC CHECKSUMS:
570570

571571
PODFILE CHECKSUM: 0dce4b7944944a0de16fd6cacc29aa20d6858b4f
572572

573-
COCOAPODS: 1.11.3
573+
COCOAPODS: 1.13.0

ios/RNQonversion.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ + (BOOL)requiresMainQueueSetup
5252
}];
5353
}
5454

55-
RCT_EXPORT_METHOD(purchaseProduct:(NSString *)productId offeringId:(NSString *)offeringId completion:(RCTResponseSenderBlock)completion rejecter:(RCTPromiseRejectBlock)reject) {
56-
[_qonversionSandwich purchaseProduct:productId offeringId:offeringId completion:^(NSDictionary<NSString *,id> * _Nullable result, SandwichError * _Nullable error) {
57-
[self handlePurchaseResult:result error:error completion:completion rejecter:reject];
58-
}];
59-
}
60-
6155
RCT_EXPORT_METHOD(setDefinedProperty:(NSString *)property value:(NSString *)value) {
6256
[_qonversionSandwich setDefinedProperty:property value:value];
6357
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-qonversion",
33
"title": "React Native Qonversion",
4-
"version": "6.3.1",
4+
"version": "7.0.0",
55
"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.",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",

react-native-qonversion.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ Pod::Spec.new do |s|
2222
s.requires_arc = true
2323

2424
s.dependency "React"
25-
s.dependency "QonversionSandwich", "3.3.3"
25+
s.dependency "QonversionSandwich", "4.0.0"
2626
end

src/QonversionApi.ts

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import Entitlement from './dto/Entitlement';
22
import Product from './dto/Product';
3-
import {UserPropertyKey, ProrationMode, AttributionProvider} from './dto/enums';
3+
import {UserPropertyKey, AttributionProvider} from './dto/enums';
44
import Offerings from './dto/Offerings';
55
import IntroEligibility from './dto/IntroEligibility';
66
import User from './dto/User';
77
import {EntitlementsUpdateListener} from './dto/EntitlementsUpdateListener';
88
import {PromoPurchasesListener} from './dto/PromoPurchasesListener';
99
import RemoteConfig from "./dto/RemoteConfig";
1010
import UserProperties from './dto/UserProperties';
11+
import PurchaseModel from './dto/PurchaseModel';
12+
import PurchaseUpdateModel from './dto/PurchaseUpdateModel';
1113

1214
interface QonversionApi {
1315

@@ -25,68 +27,30 @@ interface QonversionApi {
2527

2628
/**
2729
* Make a purchase and validate it through server-to-server using Qonversion's Backend
28-
*
29-
* @param productId Qonversion product identifier for purchase
30+
* @param purchaseModel necessary information for purchase
3031
* @returns the promise with the user entitlements including the ones obtained by the purchase
31-
*/
32-
purchase(productId: string): Promise<Map<string, Entitlement>>;
33-
34-
/**
35-
* Make a purchase and validate it through server-to-server using Qonversion's Backend
3632
*
37-
* @param product - Qonversion's {@link Product} object
38-
* @returns the promise with the user entitlements including the ones obtained by the purchase
33+
* @see [Making Purchases](https://documentation.qonversion.io/docs/making-purchases)
3934
*/
40-
purchaseProduct(product: Product): Promise<Map<string, Entitlement>>;
35+
purchase(purchaseModel: PurchaseModel): Promise<Map<string, Entitlement>>;
4136

4237
/**
4338
* Android only. Returns `null` if called on iOS.
4439
*
4540
* Update (upgrade/downgrade) subscription on Google Play Store and validate it through server-to-server using Qonversion's Backend
4641
*
47-
* @param productId Qonversion product identifier for purchase
48-
* @param oldProductId Qonversion product identifier from which the upgrade/downgrade will be initialized
49-
* @param prorationMode proration mode
42+
* @param purchaseUpdateModel necessary information for purchase update
5043
* @returns the promise with the user entitlements including updated ones.
5144
*
52-
* @see [Google Play Documentation](https://developer.android.com/google/play/billing/subscriptions#upgrade-downgrade)
53-
* for more details.
54-
* @see [Proration mode](https://developer.android.com/google/play/billing/subscriptions#proration)
55-
* @see [Product Center](https://qonversion.io/docs/product-center)
45+
* @see [Update policy](https://developer.android.com/google/play/billing/subscriptions#replacement-modes)
46+
* @see [Making Purchases](https://documentation.qonversion.io/docs/making-purchases)
5647
*/
57-
updatePurchase(
58-
productId: string,
59-
oldProductId: string,
60-
prorationMode: ProrationMode | undefined
61-
): Promise<Map<string, Entitlement> | null>;
62-
63-
/**
64-
* Android only. Returns `null` if called on iOS.
65-
*
66-
* Update (upgrade/downgrade) subscription on Google Play Store and validate it through server-to-server using Qonversion's Backend
67-
*
68-
* @param product Qonversion product for purchase
69-
* @param oldProductId Qonversion product identifier from which the upgrade/downgrade will be initialized
70-
* @param prorationMode proration mode
71-
* @returns the promise with the user entitlements including updated ones
72-
*
73-
* @see [Google Play Documentation](https://developer.android.com/google/play/billing/subscriptions#upgrade-downgrade)
74-
* for more details.
75-
* @see [Proration mode](https://developer.android.com/google/play/billing/subscriptions#proration)
76-
* @see [Product Center](https://qonversion.io/docs/product-center)
77-
*/
78-
updatePurchaseWithProduct(
79-
product: Product,
80-
oldProductId: String,
81-
prorationMode: ProrationMode | undefined
82-
): Promise<Map<string, Entitlement> | null>;
48+
updatePurchase(purchaseUpdateModel: PurchaseUpdateModel): Promise<Map<string, Entitlement> | null>;
8349

8450
/**
8551
* Returns Qonversion products in association with Apple and Google Play Store Products.
8652
*
8753
* @returns the promise with Qonversion products
88-
*
89-
* @see [Product Center](https://qonversion.io/docs/product-center)
9054
*/
9155
products(): Promise<Map<string, Product>>;
9256

@@ -101,7 +65,6 @@ interface QonversionApi {
10165
* @returns the promise with Qonversion offerings
10266
*
10367
* @see [Offerings](https://qonversion.io/docs/offerings) for more details
104-
* @see [Product Center](https://qonversion.io/docs/product-center) for more details
10568
*/
10669
offerings(): Promise<Offerings | null>;
10770

0 commit comments

Comments
 (0)