react-native-purchases 4.6.1 → 5.0.0-beta.3
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/README.md +11 -19
- package/RNPurchases.podspec +2 -2
- package/android/build.gradle +2 -2
- package/android/build.gradle.bck +126 -0
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java +24 -43
- package/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java.bck +379 -0
- package/dist/{purchaserInfo.d.ts → customerInfo.d.ts} +4 -5
- package/dist/{purchaserInfo.js → customerInfo.js} +0 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/offerings.d.ts +12 -44
- package/dist/offerings.js +4 -0
- package/dist/purchases.d.ts +67 -114
- package/dist/purchases.js +61 -163
- package/ios/RNPurchases.h +2 -2
- package/ios/RNPurchases.m +42 -74
- package/ios/RNPurchases.m.bck +343 -0
- package/package.json +5 -6
- package/scripts/{build.js → build.js.bck} +0 -0
- package/scripts/docs/index.html +9 -0
- package/scripts/docs/index.html.bck +9 -0
- package/scripts/setupJest.js +253 -243
- package/scripts/download-purchases-common.sh +0 -39
- package/scripts/download-purchases-framework.sh +0 -39
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ React Native Purchases is a client for the [RevenueCat](https://www.revenuecat.c
|
|
|
23
23
|
|
|
24
24
|
## Requirements
|
|
25
25
|
|
|
26
|
-
The minimum React Native version this SDK requires is `0.
|
|
26
|
+
The minimum React Native version this SDK requires is `0.64`.
|
|
27
27
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
|
@@ -53,33 +53,25 @@ pod 'RNPurchases', :path => '../node_modules/react-native-purchases'
|
|
|
53
53
|
|
|
54
54
|
In your `ios` folder, run `pod install`. If you've just upgraded ExpoKit, you might need to upgrade cocoapods to the newest version: `sudo gem install cocoapods`.
|
|
55
55
|
|
|
56
|
-
####
|
|
56
|
+
#### Migrating from manual installation (if your project doesn't use CocoapodsCreate)
|
|
57
57
|
|
|
58
|
-
#####
|
|
58
|
+
##### Remove the Framework Reference from your project
|
|
59
59
|
|
|
60
|
-
1.
|
|
60
|
+
1. Remove `Purchases.framework` and `PurchasesHybridCommon.framework` from the libraries section of the project.
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
##### Add iOS Frameworks to Embedded Binaries
|
|
62
|
+
##### Remove iOS Frameworks to Embedded Binaries
|
|
65
63
|
1. In Xcode, in project manager, select your app target.
|
|
66
64
|
1. Select the general tab
|
|
67
|
-
1.
|
|
68
|
-
|
|
69
|
-

|
|
65
|
+
1. Look for `Purchases.framework` and `PurchasesHybridCommon.framework` in the Embedded Binaries section and remove them.
|
|
70
66
|
|
|
71
|
-
|
|
67
|
+
Remove `$(PROJECT_DIR)/../node_modules/react-native-purchases/ios` from Framework Search paths in build settings
|
|
72
68
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
##### Add Strip Frameworks Phase
|
|
76
|
-
The App Store, in it's infinite wisdom, still rejects fat frameworks, so we need to strip our framework before it is deployed. To do this, add the following script phase to your build.
|
|
69
|
+
##### Remove Strip Frameworks Phase
|
|
70
|
+
During the old manual installation instructions, now deprecated, we indicated to add a build phase to strip fat frameworks.
|
|
77
71
|
1. In Xcode, in project manager, select your app target.
|
|
78
72
|
2. Open the `Build Phases` tab
|
|
79
|
-
3.
|
|
80
|
-
4.
|
|
81
|
-
|
|
82
|
-

|
|
73
|
+
3. Remove the added `Strip Frameworks` phase
|
|
74
|
+
4. Clean `Derived Data`
|
|
83
75
|
|
|
84
76
|
##### Link static library
|
|
85
77
|
The `react-native link` command should have added the `libRNPurchases.a` library to the _Linked Frameworks and Libraries_ section of your app target. If it hasn't add it like this:
|
package/RNPurchases.podspec
CHANGED
|
@@ -10,7 +10,7 @@ Pod::Spec.new do |spec|
|
|
|
10
10
|
spec.authors = package['author']
|
|
11
11
|
spec.homepage = "https://github.com/RevenueCat/react-native-purchases"
|
|
12
12
|
spec.license = package['license']
|
|
13
|
-
spec.platform = :ios, "
|
|
13
|
+
spec.platform = :ios, "11.0"
|
|
14
14
|
|
|
15
15
|
spec.source = { :git => "https://github.com/RevenueCat/react-native-purchases.git" }
|
|
16
16
|
spec.source_files = "ios/**/*.{h,m,swift}"
|
|
@@ -24,6 +24,6 @@ Pod::Spec.new do |spec|
|
|
|
24
24
|
]
|
|
25
25
|
|
|
26
26
|
spec.dependency "React-Core"
|
|
27
|
-
spec.dependency "PurchasesHybridCommon", '
|
|
27
|
+
spec.dependency "PurchasesHybridCommon", '4.0.0'
|
|
28
28
|
spec.swift_version = '5.0'
|
|
29
29
|
end
|
package/android/build.gradle
CHANGED
|
@@ -29,7 +29,7 @@ android {
|
|
|
29
29
|
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
|
|
30
30
|
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
31
31
|
versionCode 1
|
|
32
|
-
versionName '
|
|
32
|
+
versionName '5.0.0-beta.3'
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
buildTypes {
|
|
@@ -121,6 +121,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
|
121
121
|
dependencies {
|
|
122
122
|
//noinspection GradleDynamicVersion
|
|
123
123
|
api 'com.facebook.react:react-native:+'
|
|
124
|
-
implementation 'com.revenuecat.purchases:purchases-hybrid-common:
|
|
124
|
+
implementation 'com.revenuecat.purchases:purchases-hybrid-common:4.0.0'
|
|
125
125
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
126
126
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['Purchases_kotlinVersion']
|
|
3
|
+
repositories {
|
|
4
|
+
google()
|
|
5
|
+
mavenCentral()
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
dependencies {
|
|
9
|
+
classpath 'com.android.tools.build:gradle:4.0.1'
|
|
10
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
apply plugin: 'com.android.library'
|
|
15
|
+
apply plugin: 'kotlin-android'
|
|
16
|
+
|
|
17
|
+
def getExtOrDefault(name) {
|
|
18
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['Purchases_' + name]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
def getExtOrIntegerDefault(name) {
|
|
22
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['Purchases_' + name]).toInteger()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
android {
|
|
26
|
+
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
27
|
+
|
|
28
|
+
defaultConfig {
|
|
29
|
+
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
|
|
30
|
+
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
31
|
+
versionCode 1
|
|
32
|
+
versionName '5.0.0-beta.2'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
buildTypes {
|
|
36
|
+
release {
|
|
37
|
+
minifyEnabled false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
lintOptions {
|
|
41
|
+
disable 'GradleCompatible'
|
|
42
|
+
}
|
|
43
|
+
compileOptions {
|
|
44
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
45
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
repositories {
|
|
50
|
+
mavenCentral()
|
|
51
|
+
google()
|
|
52
|
+
|
|
53
|
+
def found = false
|
|
54
|
+
def defaultDir = null
|
|
55
|
+
def androidSourcesName = 'React Native sources'
|
|
56
|
+
|
|
57
|
+
if (rootProject.ext.has('reactNativeAndroidRoot')) {
|
|
58
|
+
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
|
|
59
|
+
} else {
|
|
60
|
+
defaultDir = new File(
|
|
61
|
+
projectDir,
|
|
62
|
+
'/../../../node_modules/react-native/android'
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (defaultDir.exists()) {
|
|
67
|
+
maven {
|
|
68
|
+
url defaultDir.toString()
|
|
69
|
+
name androidSourcesName
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
|
|
73
|
+
found = true
|
|
74
|
+
} else {
|
|
75
|
+
def parentDir = rootProject.projectDir
|
|
76
|
+
|
|
77
|
+
1.upto(5, {
|
|
78
|
+
if (found) return true
|
|
79
|
+
parentDir = parentDir.parentFile
|
|
80
|
+
|
|
81
|
+
def androidSourcesDir = new File(
|
|
82
|
+
parentDir,
|
|
83
|
+
'node_modules/react-native'
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
def androidPrebuiltBinaryDir = new File(
|
|
87
|
+
parentDir,
|
|
88
|
+
'node_modules/react-native/android'
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
if (androidPrebuiltBinaryDir.exists()) {
|
|
92
|
+
maven {
|
|
93
|
+
url androidPrebuiltBinaryDir.toString()
|
|
94
|
+
name androidSourcesName
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
|
|
98
|
+
found = true
|
|
99
|
+
} else if (androidSourcesDir.exists()) {
|
|
100
|
+
maven {
|
|
101
|
+
url androidSourcesDir.toString()
|
|
102
|
+
name androidSourcesName
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
|
|
106
|
+
found = true
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!found) {
|
|
112
|
+
throw new GradleException(
|
|
113
|
+
"${project.name}: unable to locate React Native android sources. " +
|
|
114
|
+
"Ensure you have you installed React Native as a dependency in your project and try again."
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
120
|
+
|
|
121
|
+
dependencies {
|
|
122
|
+
//noinspection GradleDynamicVersion
|
|
123
|
+
api 'com.facebook.react:react-native:+'
|
|
124
|
+
implementation 'com.revenuecat.purchases:purchases-hybrid-common:4.0.0'
|
|
125
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
126
|
+
}
|
|
@@ -14,8 +14,9 @@ import com.facebook.react.bridge.ReadableArray;
|
|
|
14
14
|
import com.facebook.react.bridge.ReadableMap;
|
|
15
15
|
import com.facebook.react.bridge.WritableArray;
|
|
16
16
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
17
|
-
import com.revenuecat.purchases.
|
|
17
|
+
import com.revenuecat.purchases.CustomerInfo;
|
|
18
18
|
import com.revenuecat.purchases.Purchases;
|
|
19
|
+
import com.revenuecat.purchases.Store;
|
|
19
20
|
import com.revenuecat.purchases.common.PlatformInfo;
|
|
20
21
|
import com.revenuecat.purchases.hybridcommon.CommonKt;
|
|
21
22
|
import com.revenuecat.purchases.hybridcommon.ErrorContainer;
|
|
@@ -23,9 +24,8 @@ import com.revenuecat.purchases.hybridcommon.OnResult;
|
|
|
23
24
|
import com.revenuecat.purchases.hybridcommon.OnResultAny;
|
|
24
25
|
import com.revenuecat.purchases.hybridcommon.OnResultList;
|
|
25
26
|
import com.revenuecat.purchases.hybridcommon.SubscriberAttributesKt;
|
|
26
|
-
import com.revenuecat.purchases.hybridcommon.mappers.
|
|
27
|
-
import com.revenuecat.purchases.interfaces.
|
|
28
|
-
import com.revenuecat.purchases.interfaces.Callback;
|
|
27
|
+
import com.revenuecat.purchases.hybridcommon.mappers.CustomerInfoMapperKt;
|
|
28
|
+
import com.revenuecat.purchases.interfaces.UpdatedCustomerInfoListener;
|
|
29
29
|
|
|
30
30
|
import org.jetbrains.annotations.NotNull;
|
|
31
31
|
import org.json.JSONException;
|
|
@@ -39,11 +39,11 @@ import kotlin.UninitializedPropertyAccessException;
|
|
|
39
39
|
|
|
40
40
|
import static com.revenuecat.purchases.react.RNPurchasesConverters.convertMapToWriteableMap;
|
|
41
41
|
|
|
42
|
-
public class RNPurchasesModule extends ReactContextBaseJavaModule implements
|
|
42
|
+
public class RNPurchasesModule extends ReactContextBaseJavaModule implements UpdatedCustomerInfoListener {
|
|
43
43
|
|
|
44
|
-
private static final String
|
|
44
|
+
private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
|
|
45
45
|
public static final String PLATFORM_NAME = "react-native";
|
|
46
|
-
public static final String PLUGIN_VERSION = "4.6.
|
|
46
|
+
public static final String PLUGIN_VERSION = "4.6.0";
|
|
47
47
|
|
|
48
48
|
private final ReactApplicationContext reactContext;
|
|
49
49
|
|
|
@@ -79,10 +79,15 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
79
79
|
|
|
80
80
|
@ReactMethod
|
|
81
81
|
public void setupPurchases(String apiKey, @Nullable String appUserID,
|
|
82
|
-
boolean observerMode, @Nullable String userDefaultsSuiteName
|
|
82
|
+
boolean observerMode, @Nullable String userDefaultsSuiteName,
|
|
83
|
+
@Nullable Boolean usesStoreKit2IfAvailable, boolean useAmazon) {
|
|
83
84
|
PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
Store store = Store.PLAY_STORE;
|
|
86
|
+
if (useAmazon) {
|
|
87
|
+
store = Store.AMAZON;
|
|
88
|
+
}
|
|
89
|
+
CommonKt.configure(reactContext, apiKey, appUserID, observerMode, platformInfo, store);
|
|
90
|
+
Purchases.getSharedInstance().setUpdatedCustomerInfoListener(this);
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
@ReactMethod
|
|
@@ -90,15 +95,6 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
90
95
|
CommonKt.setAllowSharingAppStoreAccount(allowSharingStoreAccount);
|
|
91
96
|
}
|
|
92
97
|
|
|
93
|
-
@ReactMethod
|
|
94
|
-
public void addAttributionData(ReadableMap data, Integer network, @Nullable String networkUserId) {
|
|
95
|
-
try {
|
|
96
|
-
SubscriberAttributesKt.addAttributionData(RNPurchasesConverters.convertReadableMapToJson(data), network, networkUserId);
|
|
97
|
-
} catch (JSONException e) {
|
|
98
|
-
Log.e("RNPurchases", "Error parsing attribution date to JSON: " + e.getLocalizedMessage());
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
98
|
@ReactMethod
|
|
103
99
|
public void getOfferings(final Promise promise) {
|
|
104
100
|
CommonKt.getOfferings(getOnResult(promise));
|
|
@@ -164,8 +160,8 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
164
160
|
}
|
|
165
161
|
|
|
166
162
|
@ReactMethod
|
|
167
|
-
public void
|
|
168
|
-
CommonKt.
|
|
163
|
+
public void restorePurchases(final Promise promise) {
|
|
164
|
+
CommonKt.restorePurchases(getOnResult(promise));
|
|
169
165
|
}
|
|
170
166
|
|
|
171
167
|
@ReactMethod
|
|
@@ -178,29 +174,14 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
178
174
|
CommonKt.logIn(appUserID, getOnResult(promise));
|
|
179
175
|
}
|
|
180
176
|
|
|
181
|
-
@ReactMethod
|
|
182
|
-
public void reset(final Promise promise) {
|
|
183
|
-
CommonKt.reset(getOnResult(promise));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
@ReactMethod
|
|
187
|
-
public void identify(String appUserID, final Promise promise) {
|
|
188
|
-
CommonKt.identify(appUserID, getOnResult(promise));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
@ReactMethod
|
|
192
|
-
public void createAlias(String newAppUserID, final Promise promise) {
|
|
193
|
-
CommonKt.createAlias(newAppUserID, getOnResult(promise));
|
|
194
|
-
}
|
|
195
|
-
|
|
196
177
|
@ReactMethod
|
|
197
178
|
public void setDebugLogsEnabled(boolean enabled) {
|
|
198
179
|
CommonKt.setDebugLogsEnabled(enabled);
|
|
199
180
|
}
|
|
200
181
|
|
|
201
182
|
@ReactMethod
|
|
202
|
-
public void
|
|
203
|
-
CommonKt.
|
|
183
|
+
public void getCustomerInfo(final Promise promise) {
|
|
184
|
+
CommonKt.getCustomerInfo(getOnResult(promise));
|
|
204
185
|
}
|
|
205
186
|
|
|
206
187
|
@ReactMethod
|
|
@@ -228,15 +209,15 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
228
209
|
}
|
|
229
210
|
|
|
230
211
|
@Override
|
|
231
|
-
public void onReceived(@NonNull
|
|
212
|
+
public void onReceived(@NonNull CustomerInfo customerInfo) {
|
|
232
213
|
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
233
|
-
.emit(RNPurchasesModule.
|
|
234
|
-
convertMapToWriteableMap(
|
|
214
|
+
.emit(RNPurchasesModule.CUSTOMER_INFO_UPDATED,
|
|
215
|
+
convertMapToWriteableMap(CustomerInfoMapperKt.map(customerInfo)));
|
|
235
216
|
}
|
|
236
217
|
|
|
237
218
|
@ReactMethod
|
|
238
|
-
public void
|
|
239
|
-
CommonKt.
|
|
219
|
+
public void invalidateCustomerInfoCache() {
|
|
220
|
+
CommonKt.invalidateCustomerInfoCache();
|
|
240
221
|
}
|
|
241
222
|
|
|
242
223
|
@ReactMethod
|