react-native-purchases 10.16.0 → 11.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Package.swift +35 -0
- package/README.md +22 -3
- package/RNPurchases.podspec +1 -1
- package/android/build.gradle +2 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java +24 -8
- package/dist/browser/nativeModule.d.ts +2 -2
- package/dist/browser/nativeModule.js +2 -2
- package/dist/purchases.d.ts +33 -6
- package/dist/purchases.js +9 -8
- package/ios/RNPurchases.m +1 -1
- package/package.json +9 -4
package/Package.swift
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
|
|
3
|
+
// Experimental SwiftPM integration requires React Native 0.88 or later.
|
|
4
|
+
|
|
5
|
+
import PackageDescription
|
|
6
|
+
|
|
7
|
+
let package = Package(
|
|
8
|
+
// Must match `swiftpmConfig.name` in package.json.
|
|
9
|
+
name: "ReactNativePurchases",
|
|
10
|
+
platforms: [.iOS("15.1")],
|
|
11
|
+
products: [
|
|
12
|
+
.library(name: "ReactNativePurchases", targets: ["ReactNativePurchases"]),
|
|
13
|
+
],
|
|
14
|
+
dependencies: [
|
|
15
|
+
// Resolved from the autolinker's ios/build/generated/autolinking/libs/<SwiftPM name>
|
|
16
|
+
// symlink: four levels up reaches ios/build, where RN generates xcframeworks.
|
|
17
|
+
.package(name: "ReactNative", path: "../../../../xcframeworks"),
|
|
18
|
+
.package(url: "https://github.com/RevenueCat/purchases-hybrid-common", exact: "20.4.0"),
|
|
19
|
+
],
|
|
20
|
+
targets: [
|
|
21
|
+
.target(
|
|
22
|
+
name: "ReactNativePurchases",
|
|
23
|
+
dependencies: [
|
|
24
|
+
.product(name: "ReactHeaders", package: "ReactNative"),
|
|
25
|
+
.product(name: "ReactNativeHeaders", package: "ReactNative"),
|
|
26
|
+
.product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"),
|
|
27
|
+
.product(name: "PurchasesHybridCommon", package: "purchases-hybrid-common"),
|
|
28
|
+
],
|
|
29
|
+
path: "ios",
|
|
30
|
+
exclude: ["RNPurchases.xcodeproj", "strip-frameworks.sh"],
|
|
31
|
+
publicHeadersPath: ".",
|
|
32
|
+
cSettings: [.headerSearchPath(".")]
|
|
33
|
+
),
|
|
34
|
+
]
|
|
35
|
+
)
|
package/README.md
CHANGED
|
@@ -44,8 +44,8 @@ Or view our React Native sample app:
|
|
|
44
44
|
|
|
45
45
|
## Requirements
|
|
46
46
|
|
|
47
|
-
The minimum React Native version this SDK requires is `0.
|
|
48
|
-
In Android, minimum Kotlin version is `1.
|
|
47
|
+
The minimum React Native version this SDK requires is `0.80.0`.
|
|
48
|
+
In Android, minimum Kotlin version is `2.1.0`.
|
|
49
49
|
|
|
50
50
|
## SDK Reference
|
|
51
51
|
Our full SDK reference [can be found here](https://revenuecat.github.io/react-native-purchases-docs/).
|
|
@@ -54,6 +54,25 @@ Our full SDK reference [can be found here](https://revenuecat.github.io/react-na
|
|
|
54
54
|
|
|
55
55
|
## Installation
|
|
56
56
|
|
|
57
|
+
### Experimental Swift Package Manager support (iOS)
|
|
58
|
+
|
|
59
|
+
Both `react-native-purchases` and `react-native-purchases-ui` include Swift package
|
|
60
|
+
manifests for React Native's experimental Swift Package Manager integration.
|
|
61
|
+
This integration requires React Native **0.88.0 or later**. CocoaPods remains
|
|
62
|
+
supported, with a minimum React Native version of **0.80.0**.
|
|
63
|
+
|
|
64
|
+
Install or upgrade the SDK packages first, then follow
|
|
65
|
+
[React Native's SwiftPM setup instructions](https://github.com/react/react-native/blob/v0.88.0/packages/react-native/scripts/spm/__docs__/spm-scripts.md#quick-start)
|
|
66
|
+
to configure your app. Both SDK packages include the required SwiftPM manifests,
|
|
67
|
+
so you don't need to scaffold them.
|
|
68
|
+
|
|
69
|
+
For apps without a Podfile, React Native Community CLI **21.0.0-alpha.1** is
|
|
70
|
+
currently required for project discovery. Library podspecs are still required
|
|
71
|
+
for React Native's dependency discovery,
|
|
72
|
+
including when the app uses SwiftPM.
|
|
73
|
+
|
|
74
|
+
### Expo
|
|
75
|
+
|
|
57
76
|
Expo supports in-app payments and is compatible with `react-native-purchases`. To use the SDK, [create a new project](https://docs.expo.dev/get-started/create-a-project/) and set up a [development build](https://docs.expo.dev/get-started/set-up-your-environment/?mode=development-build). Development builds enable native code and provide a complete environment for testing purchases.
|
|
58
77
|
|
|
59
78
|
```
|
|
@@ -62,6 +81,6 @@ $ npx expo install react-native-purchases
|
|
|
62
81
|
|
|
63
82
|
In Expo Go, the SDK automatically runs in **Preview API Mode**, replacing native calls with JavaScript mocks so your app loads without errors. Real purchases, however, require a development build.
|
|
64
83
|
|
|
65
|
-
|
|
84
|
+
#### Using development builds
|
|
66
85
|
|
|
67
86
|
To fully test in-app purchases, you’ll need to create a [custom development build](https://docs.expo.dev/develop/development-builds/introduction/) with EAS. This ensures that all native dependencies, including `react-native-purchases`, are properly included.
|
package/RNPurchases.podspec
CHANGED
package/android/build.gradle
CHANGED
|
@@ -35,7 +35,7 @@ android {
|
|
|
35
35
|
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
|
|
36
36
|
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
37
37
|
versionCode 1
|
|
38
|
-
versionName '
|
|
38
|
+
versionName '11.0.1'
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
buildTypes {
|
|
@@ -127,6 +127,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
|
127
127
|
dependencies {
|
|
128
128
|
//noinspection GradleDynamicVersion
|
|
129
129
|
api 'com.facebook.react:react-native:+'
|
|
130
|
-
implementation 'com.revenuecat.purchases:purchases-hybrid-common:
|
|
130
|
+
implementation 'com.revenuecat.purchases:purchases-hybrid-common:20.4.0'
|
|
131
131
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
132
132
|
}
|
|
@@ -51,7 +51,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
51
51
|
private static final String TRACKED_EVENT = "Purchases-TrackedEvent";
|
|
52
52
|
private static final String DEBUG_EVENT = "Purchases-DebugEvent";
|
|
53
53
|
public static final String PLATFORM_NAME = "react-native";
|
|
54
|
-
public static final String PLUGIN_VERSION = "
|
|
54
|
+
public static final String PLUGIN_VERSION = "11.0.1";
|
|
55
55
|
|
|
56
56
|
private final ReactApplicationContext reactContext;
|
|
57
57
|
|
|
@@ -586,20 +586,36 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
586
586
|
}
|
|
587
587
|
|
|
588
588
|
@ReactMethod
|
|
589
|
-
public void syncAmazonPurchase(
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
589
|
+
public void syncAmazonPurchase(ReadableMap options, final Promise promise) {
|
|
590
|
+
String productID = options.getString("productID");
|
|
591
|
+
String receiptID = options.getString("receiptID");
|
|
592
|
+
String amazonUserID = options.getString("amazonUserID");
|
|
593
|
+
boolean hasPurchaseTime = options.hasKey("purchaseTime") && !options.isNull("purchaseTime");
|
|
594
|
+
if (productID == null || receiptID == null || amazonUserID == null || !hasPurchaseTime) {
|
|
595
|
+
promise.reject("InvalidArguments",
|
|
596
|
+
"syncAmazonPurchase requires productID, receiptID, amazonUserID and purchaseTime");
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
String isoCurrencyCode = options.hasKey("isoCurrencyCode") && !options.isNull("isoCurrencyCode")
|
|
600
|
+
? options.getString("isoCurrencyCode") : null;
|
|
601
|
+
Double price = options.hasKey("price") && !options.isNull("price")
|
|
602
|
+
? options.getDouble("price") : null;
|
|
603
|
+
// JS numbers cross the bridge as doubles; epoch millis are exactly representable.
|
|
604
|
+
long purchaseTime = (long) options.getDouble("purchaseTime");
|
|
605
|
+
Purchases.getSharedInstance().syncAmazonPurchase(productID, receiptID,
|
|
606
|
+
amazonUserID, isoCurrencyCode, price, purchaseTime);
|
|
607
|
+
promise.resolve(null);
|
|
595
608
|
}
|
|
596
609
|
|
|
597
610
|
@ReactMethod
|
|
598
611
|
@Deprecated // Use syncAmazonPurchase instead
|
|
612
|
+
@SuppressWarnings("deprecation")
|
|
599
613
|
public void syncObserverModeAmazonPurchase(String productID, String receiptID,
|
|
600
614
|
String amazonUserID, String isoCurrencyCode,
|
|
601
615
|
Double price, final Promise promise) {
|
|
602
|
-
syncAmazonPurchase(productID, receiptID,
|
|
616
|
+
Purchases.getSharedInstance().syncAmazonPurchase(productID, receiptID,
|
|
617
|
+
amazonUserID, isoCurrencyCode, price);
|
|
618
|
+
promise.resolve(null);
|
|
603
619
|
}
|
|
604
620
|
|
|
605
621
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MakePurchaseResult } from '@revenuecat/purchases-typescript-internal';
|
|
2
|
-
import type { RewardedAdTrackingMetadata } from '../purchases';
|
|
2
|
+
import type { RewardedAdTrackingMetadata, SyncAmazonPurchaseOptions } from '../purchases';
|
|
3
3
|
/**
|
|
4
4
|
* Browser implementation of the native module. This will be used in the browser and Expo Go.
|
|
5
5
|
*/
|
|
@@ -27,7 +27,7 @@ export declare const browserNativeModuleRNPurchases: {
|
|
|
27
27
|
logOut: () => Promise<import("@revenuecat/purchases-typescript-internal").CustomerInfo>;
|
|
28
28
|
syncPurchases: () => Promise<void>;
|
|
29
29
|
syncPurchasesForResult: () => Promise<void>;
|
|
30
|
-
syncAmazonPurchase: (
|
|
30
|
+
syncAmazonPurchase: (_options: SyncAmazonPurchaseOptions) => Promise<void>;
|
|
31
31
|
syncObserverModeAmazonPurchase: (_productID: string, _receiptID: string, _amazonUserID: string, _isoCurrencyCode: string | null, _price: number | null) => Promise<void>;
|
|
32
32
|
recordPurchaseForProductID: (_productID: string) => Promise<void>;
|
|
33
33
|
enableAdServicesAttributionTokenCollection: () => Promise<void>;
|
|
@@ -43,7 +43,7 @@ var typeGuards_1 = require("./typeGuards");
|
|
|
43
43
|
var environment_1 = require("../utils/environment");
|
|
44
44
|
var utils_1 = require("./utils");
|
|
45
45
|
var purchaseSimulatedPackageHelper_1 = require("./simulatedstore/purchaseSimulatedPackageHelper");
|
|
46
|
-
var packageVersion = '
|
|
46
|
+
var packageVersion = '11.0.1';
|
|
47
47
|
/**
|
|
48
48
|
* Browser implementation of the native module. This will be used in the browser and Expo Go.
|
|
49
49
|
*/
|
|
@@ -232,7 +232,7 @@ exports.browserNativeModuleRNPurchases = {
|
|
|
232
232
|
return [2 /*return*/];
|
|
233
233
|
});
|
|
234
234
|
}); },
|
|
235
|
-
syncAmazonPurchase: function (
|
|
235
|
+
syncAmazonPurchase: function (_options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
236
236
|
return __generator(this, function (_a) {
|
|
237
237
|
(0, utils_1.methodNotSupportedOnWeb)('syncAmazonPurchase');
|
|
238
238
|
return [2 /*return*/];
|
package/dist/purchases.d.ts
CHANGED
|
@@ -41,6 +41,36 @@ export interface TrackCustomPaywallImpressionOptions {
|
|
|
41
41
|
*/
|
|
42
42
|
offeringId?: string | null;
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Options for syncing an Amazon purchase with the RevenueCat backend.
|
|
46
|
+
*/
|
|
47
|
+
export interface SyncAmazonPurchaseOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Product ID associated to the purchase.
|
|
50
|
+
*/
|
|
51
|
+
productID: string;
|
|
52
|
+
/**
|
|
53
|
+
* ReceiptId that represents the Amazon purchase.
|
|
54
|
+
*/
|
|
55
|
+
receiptID: string;
|
|
56
|
+
/**
|
|
57
|
+
* Amazon's userID. This parameter will be ignored when syncing a Google purchase.
|
|
58
|
+
*/
|
|
59
|
+
amazonUserID: string;
|
|
60
|
+
/**
|
|
61
|
+
* Product's currency code in ISO 4217 format.
|
|
62
|
+
*/
|
|
63
|
+
isoCurrencyCode?: string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Product's price.
|
|
66
|
+
*/
|
|
67
|
+
price?: number | null;
|
|
68
|
+
/**
|
|
69
|
+
* Time the product was purchased, in milliseconds since the epoch. Can be obtained from Amazon's
|
|
70
|
+
* PurchaseResponse > Receipt > purchaseTime.
|
|
71
|
+
*/
|
|
72
|
+
purchaseTime: number;
|
|
73
|
+
}
|
|
44
74
|
/**
|
|
45
75
|
* Predefined mediator name constants. Use these or pass any string for unlisted networks.
|
|
46
76
|
*/
|
|
@@ -577,15 +607,12 @@ export default class Purchases {
|
|
|
577
607
|
*
|
|
578
608
|
* The receipt IDs are cached if successfully posted so they are not posted more than once.
|
|
579
609
|
*
|
|
580
|
-
* @param {
|
|
581
|
-
*
|
|
582
|
-
* @param {string} amazonUserID Amazon's userID. This parameter will be ignored when syncing a Google purchase.
|
|
583
|
-
* @param {(string|null|undefined)} isoCurrencyCode Product's currency code in ISO 4217 format.
|
|
584
|
-
* @param {(number|null|undefined)} price Product's price.
|
|
610
|
+
* @param {SyncAmazonPurchaseOptions} options The purchase details. `purchaseTime` is required and can be
|
|
611
|
+
* obtained from Amazon's PurchaseResponse > Receipt > purchaseTime.
|
|
585
612
|
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet or if there's an error
|
|
586
613
|
* syncing purchases.
|
|
587
614
|
*/
|
|
588
|
-
static syncAmazonPurchase(
|
|
615
|
+
static syncAmazonPurchase(options: SyncAmazonPurchaseOptions): Promise<void>;
|
|
589
616
|
/**
|
|
590
617
|
* @deprecated, use syncAmazonPurchase instead.
|
|
591
618
|
*
|
package/dist/purchases.js
CHANGED
|
@@ -877,15 +877,12 @@ var Purchases = /** @class */ (function () {
|
|
|
877
877
|
*
|
|
878
878
|
* The receipt IDs are cached if successfully posted so they are not posted more than once.
|
|
879
879
|
*
|
|
880
|
-
* @param {
|
|
881
|
-
*
|
|
882
|
-
* @param {string} amazonUserID Amazon's userID. This parameter will be ignored when syncing a Google purchase.
|
|
883
|
-
* @param {(string|null|undefined)} isoCurrencyCode Product's currency code in ISO 4217 format.
|
|
884
|
-
* @param {(number|null|undefined)} price Product's price.
|
|
880
|
+
* @param {SyncAmazonPurchaseOptions} options The purchase details. `purchaseTime` is required and can be
|
|
881
|
+
* obtained from Amazon's PurchaseResponse > Receipt > purchaseTime.
|
|
885
882
|
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet or if there's an error
|
|
886
883
|
* syncing purchases.
|
|
887
884
|
*/
|
|
888
|
-
Purchases.syncAmazonPurchase = function (
|
|
885
|
+
Purchases.syncAmazonPurchase = function (options) {
|
|
889
886
|
return __awaiter(this, void 0, void 0, function () {
|
|
890
887
|
return __generator(this, function (_a) {
|
|
891
888
|
switch (_a.label) {
|
|
@@ -895,7 +892,9 @@ var Purchases = /** @class */ (function () {
|
|
|
895
892
|
return [4 /*yield*/, throwIfNotConfigured()];
|
|
896
893
|
case 2:
|
|
897
894
|
_a.sent();
|
|
898
|
-
RNPurchases.syncAmazonPurchase(
|
|
895
|
+
return [4 /*yield*/, RNPurchases.syncAmazonPurchase(options)];
|
|
896
|
+
case 3:
|
|
897
|
+
_a.sent();
|
|
899
898
|
return [2 /*return*/];
|
|
900
899
|
}
|
|
901
900
|
});
|
|
@@ -927,7 +926,9 @@ var Purchases = /** @class */ (function () {
|
|
|
927
926
|
return [4 /*yield*/, throwIfNotConfigured()];
|
|
928
927
|
case 2:
|
|
929
928
|
_a.sent();
|
|
930
|
-
RNPurchases.syncObserverModeAmazonPurchase(productID, receiptID, amazonUserID, isoCurrencyCode, price);
|
|
929
|
+
return [4 /*yield*/, RNPurchases.syncObserverModeAmazonPurchase(productID, receiptID, amazonUserID, isoCurrencyCode, price)];
|
|
930
|
+
case 3:
|
|
931
|
+
_a.sent();
|
|
931
932
|
return [2 /*return*/];
|
|
932
933
|
}
|
|
933
934
|
});
|
package/ios/RNPurchases.m
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-purchases",
|
|
3
3
|
"title": "React Native Purchases",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "11.0.1",
|
|
5
5
|
"description": "React Native in-app purchases and subscriptions made easy. Supports iOS and Android. ",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"!ios/RNPurchases.xcodeproj/project.xcworkspace",
|
|
23
23
|
"!ios/RNPurchases.xcodeproj/xcuserdata",
|
|
24
24
|
"RNPurchases.podspec",
|
|
25
|
+
"Package.swift",
|
|
25
26
|
"scripts",
|
|
26
27
|
"!**/__tests__",
|
|
27
28
|
"!**/.idea",
|
|
@@ -34,6 +35,9 @@
|
|
|
34
35
|
"!scripts/docs/index.html",
|
|
35
36
|
"!scripts/setupJest.js"
|
|
36
37
|
],
|
|
38
|
+
"swiftpmConfig": {
|
|
39
|
+
"name": "ReactNativePurchases"
|
|
40
|
+
},
|
|
37
41
|
"scripts": {
|
|
38
42
|
"build": "tsc",
|
|
39
43
|
"build-watch": "tsc --watch",
|
|
@@ -73,7 +77,7 @@
|
|
|
73
77
|
"readmeFilename": "README.md",
|
|
74
78
|
"peerDependencies": {
|
|
75
79
|
"react": ">= 16.6.3",
|
|
76
|
-
"react-native": ">= 0.
|
|
80
|
+
"react-native": ">= 0.80.0",
|
|
77
81
|
"react-native-web": "*"
|
|
78
82
|
},
|
|
79
83
|
"peerDependenciesMeta": {
|
|
@@ -109,6 +113,7 @@
|
|
|
109
113
|
"jest": {
|
|
110
114
|
"preset": "@react-native/jest-preset",
|
|
111
115
|
"modulePathIgnorePatterns": [
|
|
116
|
+
"<rootDir>/e2e-tests/",
|
|
112
117
|
"<rootDir>/examples/purchaseTesterTypescript/",
|
|
113
118
|
"<rootDir>/react-native-purchases-admob/",
|
|
114
119
|
"<rootDir>/react-native-purchases-store-galaxy/",
|
|
@@ -124,7 +129,7 @@
|
|
|
124
129
|
]
|
|
125
130
|
},
|
|
126
131
|
"dependencies": {
|
|
127
|
-
"@revenuecat/purchases-js-hybrid-mappings": "
|
|
128
|
-
"@revenuecat/purchases-typescript-internal": "
|
|
132
|
+
"@revenuecat/purchases-js-hybrid-mappings": "20.4.0",
|
|
133
|
+
"@revenuecat/purchases-typescript-internal": "20.4.0"
|
|
129
134
|
}
|
|
130
135
|
}
|