react-native-purchases 4.6.1 → 5.0.0-beta.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/README.md +10 -18
- 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 +18 -42
- package/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java.bck +374 -0
- package/dist/{purchaserInfo.d.ts → customerInfo.d.ts} +4 -5
- package/dist/{purchaserInfo.js → customerInfo.js} +0 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/offerings.d.ts +11 -43
- package/dist/offerings.js +4 -0
- package/dist/purchases.d.ts +52 -114
- package/dist/purchases.js +52 -160
- package/ios/RNPurchases.h +2 -2
- package/ios/RNPurchases.m +39 -72
- package/ios/RNPurchases.m.bck +342 -0
- package/package.json +4 -6
- package/scripts/{build.js → build.js.bck} +0 -0
- package/scripts/setupJest.js +5 -9
- package/scripts/download-purchases-common.sh +0 -39
- package/scripts/download-purchases-framework.sh +0 -39
package/README.md
CHANGED
|
@@ -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", '3.3.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.1'
|
|
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:3.3.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 '4.6.1'
|
|
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:3.3.0'
|
|
125
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
126
|
+
}
|
|
@@ -14,7 +14,7 @@ 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
19
|
import com.revenuecat.purchases.common.PlatformInfo;
|
|
20
20
|
import com.revenuecat.purchases.hybridcommon.CommonKt;
|
|
@@ -23,9 +23,8 @@ import com.revenuecat.purchases.hybridcommon.OnResult;
|
|
|
23
23
|
import com.revenuecat.purchases.hybridcommon.OnResultAny;
|
|
24
24
|
import com.revenuecat.purchases.hybridcommon.OnResultList;
|
|
25
25
|
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;
|
|
26
|
+
import com.revenuecat.purchases.hybridcommon.mappers.CustomerInfoMapperKt;
|
|
27
|
+
import com.revenuecat.purchases.interfaces.UpdatedCustomerInfoListener;
|
|
29
28
|
|
|
30
29
|
import org.jetbrains.annotations.NotNull;
|
|
31
30
|
import org.json.JSONException;
|
|
@@ -39,11 +38,11 @@ import kotlin.UninitializedPropertyAccessException;
|
|
|
39
38
|
|
|
40
39
|
import static com.revenuecat.purchases.react.RNPurchasesConverters.convertMapToWriteableMap;
|
|
41
40
|
|
|
42
|
-
public class RNPurchasesModule extends ReactContextBaseJavaModule implements
|
|
41
|
+
public class RNPurchasesModule extends ReactContextBaseJavaModule implements UpdatedCustomerInfoListener {
|
|
43
42
|
|
|
44
|
-
private static final String
|
|
43
|
+
private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
|
|
45
44
|
public static final String PLATFORM_NAME = "react-native";
|
|
46
|
-
public static final String PLUGIN_VERSION = "4.6.
|
|
45
|
+
public static final String PLUGIN_VERSION = "4.6.0";
|
|
47
46
|
|
|
48
47
|
private final ReactApplicationContext reactContext;
|
|
49
48
|
|
|
@@ -79,10 +78,11 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
79
78
|
|
|
80
79
|
@ReactMethod
|
|
81
80
|
public void setupPurchases(String apiKey, @Nullable String appUserID,
|
|
82
|
-
boolean observerMode, @Nullable String userDefaultsSuiteName
|
|
81
|
+
boolean observerMode, @Nullable String userDefaultsSuiteName,
|
|
82
|
+
@Nullable Boolean usesStoreKit2IfAvailable) {
|
|
83
83
|
PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
|
|
84
84
|
CommonKt.configure(reactContext, apiKey, appUserID, observerMode, platformInfo);
|
|
85
|
-
Purchases.getSharedInstance().
|
|
85
|
+
Purchases.getSharedInstance().setUpdatedCustomerInfoListener(this);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
@ReactMethod
|
|
@@ -90,15 +90,6 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
90
90
|
CommonKt.setAllowSharingAppStoreAccount(allowSharingStoreAccount);
|
|
91
91
|
}
|
|
92
92
|
|
|
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
93
|
@ReactMethod
|
|
103
94
|
public void getOfferings(final Promise promise) {
|
|
104
95
|
CommonKt.getOfferings(getOnResult(promise));
|
|
@@ -164,8 +155,8 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
164
155
|
}
|
|
165
156
|
|
|
166
157
|
@ReactMethod
|
|
167
|
-
public void
|
|
168
|
-
CommonKt.
|
|
158
|
+
public void restorePurchases(final Promise promise) {
|
|
159
|
+
CommonKt.restorePurchases(getOnResult(promise));
|
|
169
160
|
}
|
|
170
161
|
|
|
171
162
|
@ReactMethod
|
|
@@ -178,29 +169,14 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
178
169
|
CommonKt.logIn(appUserID, getOnResult(promise));
|
|
179
170
|
}
|
|
180
171
|
|
|
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
172
|
@ReactMethod
|
|
197
173
|
public void setDebugLogsEnabled(boolean enabled) {
|
|
198
174
|
CommonKt.setDebugLogsEnabled(enabled);
|
|
199
175
|
}
|
|
200
176
|
|
|
201
177
|
@ReactMethod
|
|
202
|
-
public void
|
|
203
|
-
CommonKt.
|
|
178
|
+
public void getCustomerInfo(final Promise promise) {
|
|
179
|
+
CommonKt.getCustomerInfo(getOnResult(promise));
|
|
204
180
|
}
|
|
205
181
|
|
|
206
182
|
@ReactMethod
|
|
@@ -228,15 +204,15 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
228
204
|
}
|
|
229
205
|
|
|
230
206
|
@Override
|
|
231
|
-
public void onReceived(@NonNull
|
|
207
|
+
public void onReceived(@NonNull CustomerInfo customerInfo) {
|
|
232
208
|
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
233
|
-
.emit(RNPurchasesModule.
|
|
234
|
-
convertMapToWriteableMap(
|
|
209
|
+
.emit(RNPurchasesModule.CUSTOMER_INFO_UPDATED,
|
|
210
|
+
convertMapToWriteableMap(CustomerInfoMapperKt.map(customerInfo)));
|
|
235
211
|
}
|
|
236
212
|
|
|
237
213
|
@ReactMethod
|
|
238
|
-
public void
|
|
239
|
-
CommonKt.
|
|
214
|
+
public void invalidateCustomerInfoCache() {
|
|
215
|
+
CommonKt.invalidateCustomerInfoCache();
|
|
240
216
|
}
|
|
241
217
|
|
|
242
218
|
@ReactMethod
|