react-native-purchases 4.6.0 → 5.0.0-beta.2
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 +3 -4
- package/android/build.gradle.bck +3 -4
- 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/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 +55 -114
- package/dist/purchases.js +55 -160
- package/ios/RNPurchases.h +2 -2
- package/ios/RNPurchases.m +41 -74
- package/ios/RNPurchases.m.bck +39 -72
- 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/android/.classpath +0 -6
- package/android/.project +0 -34
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- 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
|
@@ -2,7 +2,7 @@ buildscript {
|
|
|
2
2
|
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['Purchases_kotlinVersion']
|
|
3
3
|
repositories {
|
|
4
4
|
google()
|
|
5
|
-
|
|
5
|
+
mavenCentral()
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
dependencies {
|
|
@@ -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.2'
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
buildTypes {
|
|
@@ -48,7 +48,6 @@ android {
|
|
|
48
48
|
|
|
49
49
|
repositories {
|
|
50
50
|
mavenCentral()
|
|
51
|
-
jcenter()
|
|
52
51
|
google()
|
|
53
52
|
|
|
54
53
|
def found = false
|
|
@@ -122,6 +121,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
|
122
121
|
dependencies {
|
|
123
122
|
//noinspection GradleDynamicVersion
|
|
124
123
|
api 'com.facebook.react:react-native:+'
|
|
125
|
-
implementation 'com.revenuecat.purchases:purchases-hybrid-common:
|
|
124
|
+
implementation 'com.revenuecat.purchases:purchases-hybrid-common:4.0.0'
|
|
126
125
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
127
126
|
}
|
package/android/build.gradle.bck
CHANGED
|
@@ -2,7 +2,7 @@ buildscript {
|
|
|
2
2
|
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['Purchases_kotlinVersion']
|
|
3
3
|
repositories {
|
|
4
4
|
google()
|
|
5
|
-
|
|
5
|
+
mavenCentral()
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
dependencies {
|
|
@@ -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 {
|
|
@@ -48,7 +48,6 @@ android {
|
|
|
48
48
|
|
|
49
49
|
repositories {
|
|
50
50
|
mavenCentral()
|
|
51
|
-
jcenter()
|
|
52
51
|
google()
|
|
53
52
|
|
|
54
53
|
def found = false
|
|
@@ -122,6 +121,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
|
122
121
|
dependencies {
|
|
123
122
|
//noinspection GradleDynamicVersion
|
|
124
123
|
api 'com.facebook.react:react-native:+'
|
|
125
|
-
implementation 'com.revenuecat.purchases:purchases-hybrid-common:
|
|
124
|
+
implementation 'com.revenuecat.purchases:purchases-hybrid-common:4.0.0'
|
|
126
125
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
127
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.
|
|
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
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
package com.revenuecat.purchases.react;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
import androidx.annotation.Nullable;
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.bridge.Arguments;
|
|
9
|
+
import com.facebook.react.bridge.Promise;
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
11
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
12
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
13
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
14
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
15
|
+
import com.facebook.react.bridge.WritableArray;
|
|
16
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
17
|
+
import com.revenuecat.purchases.CustomerInfo;
|
|
18
|
+
import com.revenuecat.purchases.Purchases;
|
|
19
|
+
import com.revenuecat.purchases.common.PlatformInfo;
|
|
20
|
+
import com.revenuecat.purchases.hybridcommon.CommonKt;
|
|
21
|
+
import com.revenuecat.purchases.hybridcommon.ErrorContainer;
|
|
22
|
+
import com.revenuecat.purchases.hybridcommon.OnResult;
|
|
23
|
+
import com.revenuecat.purchases.hybridcommon.OnResultAny;
|
|
24
|
+
import com.revenuecat.purchases.hybridcommon.OnResultList;
|
|
25
|
+
import com.revenuecat.purchases.hybridcommon.SubscriberAttributesKt;
|
|
26
|
+
import com.revenuecat.purchases.hybridcommon.mappers.CustomerInfoMapperKt;
|
|
27
|
+
import com.revenuecat.purchases.interfaces.UpdatedCustomerInfoListener;
|
|
28
|
+
|
|
29
|
+
import org.jetbrains.annotations.NotNull;
|
|
30
|
+
import org.json.JSONException;
|
|
31
|
+
|
|
32
|
+
import java.util.ArrayList;
|
|
33
|
+
import java.util.HashMap;
|
|
34
|
+
import java.util.List;
|
|
35
|
+
import java.util.Map;
|
|
36
|
+
|
|
37
|
+
import kotlin.UninitializedPropertyAccessException;
|
|
38
|
+
|
|
39
|
+
import static com.revenuecat.purchases.react.RNPurchasesConverters.convertMapToWriteableMap;
|
|
40
|
+
|
|
41
|
+
public class RNPurchasesModule extends ReactContextBaseJavaModule implements UpdatedCustomerInfoListener {
|
|
42
|
+
|
|
43
|
+
private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
|
|
44
|
+
public static final String PLATFORM_NAME = "react-native";
|
|
45
|
+
public static final String PLUGIN_VERSION = "4.6.0";
|
|
46
|
+
|
|
47
|
+
private final ReactApplicationContext reactContext;
|
|
48
|
+
|
|
49
|
+
@SuppressWarnings("WeakerAccess")
|
|
50
|
+
public RNPurchasesModule(ReactApplicationContext reactContext) {
|
|
51
|
+
super(reactContext);
|
|
52
|
+
this.reactContext = reactContext;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@NonNull
|
|
56
|
+
@Override
|
|
57
|
+
public String getName() {
|
|
58
|
+
return "RNPurchases";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public void onCatalystInstanceDestroy() {
|
|
62
|
+
try {
|
|
63
|
+
Purchases.getSharedInstance().close();
|
|
64
|
+
} catch (UninitializedPropertyAccessException e) {
|
|
65
|
+
// there's no instance so all good
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@ReactMethod
|
|
70
|
+
public void addListener(String eventName) {
|
|
71
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@ReactMethod
|
|
75
|
+
public void removeListeners(Integer count) {
|
|
76
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@ReactMethod
|
|
80
|
+
public void setupPurchases(String apiKey, @Nullable String appUserID,
|
|
81
|
+
boolean observerMode, @Nullable String userDefaultsSuiteName,
|
|
82
|
+
@Nullable Boolean usesStoreKit2IfAvailable) {
|
|
83
|
+
PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
|
|
84
|
+
CommonKt.configure(reactContext, apiKey, appUserID, observerMode, platformInfo);
|
|
85
|
+
Purchases.getSharedInstance().setUpdatedCustomerInfoListener(this);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@ReactMethod
|
|
89
|
+
public void setAllowSharingStoreAccount(boolean allowSharingStoreAccount) {
|
|
90
|
+
CommonKt.setAllowSharingAppStoreAccount(allowSharingStoreAccount);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@ReactMethod
|
|
94
|
+
public void getOfferings(final Promise promise) {
|
|
95
|
+
CommonKt.getOfferings(getOnResult(promise));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@ReactMethod
|
|
99
|
+
public void getProductInfo(ReadableArray productIDs, String type, final Promise promise) {
|
|
100
|
+
ArrayList<String> productIDList = new ArrayList<>();
|
|
101
|
+
for (int i = 0; i < productIDs.size(); i++) {
|
|
102
|
+
productIDList.add(productIDs.getString(i));
|
|
103
|
+
}
|
|
104
|
+
CommonKt.getProductInfo(productIDList, type, new OnResultList() {
|
|
105
|
+
@Override
|
|
106
|
+
public void onReceived(List<Map<String, ?>> map) {
|
|
107
|
+
WritableArray writableArray = Arguments.createArray();
|
|
108
|
+
for (Map<String, ?> detail : map) {
|
|
109
|
+
writableArray.pushMap(convertMapToWriteableMap(detail));
|
|
110
|
+
}
|
|
111
|
+
promise.resolve(writableArray);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@Override
|
|
115
|
+
public void onError(ErrorContainer errorContainer) {
|
|
116
|
+
promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
|
|
117
|
+
convertMapToWriteableMap(errorContainer.getInfo()));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@ReactMethod
|
|
123
|
+
public void purchaseProduct(final String productIdentifier,
|
|
124
|
+
@Nullable final ReadableMap upgradeInfo,
|
|
125
|
+
final String type,
|
|
126
|
+
@Nullable final String discountTimestamp,
|
|
127
|
+
final Promise promise) {
|
|
128
|
+
CommonKt.purchaseProduct(
|
|
129
|
+
getCurrentActivity(),
|
|
130
|
+
productIdentifier,
|
|
131
|
+
upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null,
|
|
132
|
+
upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null,
|
|
133
|
+
type,
|
|
134
|
+
getOnResult(promise));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@ReactMethod
|
|
138
|
+
public void purchasePackage(final String packageIdentifier,
|
|
139
|
+
final String offeringIdentifier,
|
|
140
|
+
@Nullable final ReadableMap upgradeInfo,
|
|
141
|
+
@Nullable final String discountTimestamp,
|
|
142
|
+
final Promise promise) {
|
|
143
|
+
CommonKt.purchasePackage(
|
|
144
|
+
getCurrentActivity(),
|
|
145
|
+
packageIdentifier,
|
|
146
|
+
offeringIdentifier,
|
|
147
|
+
upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null,
|
|
148
|
+
upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null,
|
|
149
|
+
getOnResult(promise));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@ReactMethod
|
|
153
|
+
public void getAppUserID(final Promise promise) {
|
|
154
|
+
promise.resolve(CommonKt.getAppUserID());
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@ReactMethod
|
|
158
|
+
public void restorePurchases(final Promise promise) {
|
|
159
|
+
CommonKt.restorePurchases(getOnResult(promise));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@ReactMethod
|
|
163
|
+
public void logOut(final Promise promise) {
|
|
164
|
+
CommonKt.logOut(getOnResult(promise));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@ReactMethod
|
|
168
|
+
public void logIn(String appUserID, final Promise promise) {
|
|
169
|
+
CommonKt.logIn(appUserID, getOnResult(promise));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@ReactMethod
|
|
173
|
+
public void setDebugLogsEnabled(boolean enabled) {
|
|
174
|
+
CommonKt.setDebugLogsEnabled(enabled);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@ReactMethod
|
|
178
|
+
public void getCustomerInfo(final Promise promise) {
|
|
179
|
+
CommonKt.getCustomerInfo(getOnResult(promise));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@ReactMethod
|
|
183
|
+
public void setFinishTransactions(boolean enabled) {
|
|
184
|
+
CommonKt.setFinishTransactions(enabled);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@ReactMethod
|
|
188
|
+
public void syncPurchases() {
|
|
189
|
+
CommonKt.syncPurchases();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@ReactMethod
|
|
193
|
+
public void isAnonymous(final Promise promise) {
|
|
194
|
+
promise.resolve(CommonKt.isAnonymous());
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
@ReactMethod
|
|
198
|
+
public void checkTrialOrIntroductoryPriceEligibility(ReadableArray productIDs, final Promise promise) {
|
|
199
|
+
ArrayList<String> productIDList = new ArrayList<>();
|
|
200
|
+
for (int i = 0; i < productIDs.size(); i++) {
|
|
201
|
+
productIDList.add(productIDs.getString(i));
|
|
202
|
+
}
|
|
203
|
+
promise.resolve(convertMapToWriteableMap(CommonKt.checkTrialOrIntroductoryPriceEligibility(productIDList)));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@Override
|
|
207
|
+
public void onReceived(@NonNull CustomerInfo customerInfo) {
|
|
208
|
+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
209
|
+
.emit(RNPurchasesModule.CUSTOMER_INFO_UPDATED,
|
|
210
|
+
convertMapToWriteableMap(CustomerInfoMapperKt.map(customerInfo)));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@ReactMethod
|
|
214
|
+
public void invalidateCustomerInfoCache() {
|
|
215
|
+
CommonKt.invalidateCustomerInfoCache();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@ReactMethod
|
|
219
|
+
public void setProxyURLString(String proxyURLString) {
|
|
220
|
+
CommonKt.setProxyURLString(proxyURLString);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@ReactMethod
|
|
224
|
+
public void isConfigured(Promise promise) {
|
|
225
|
+
promise.resolve(Purchases.isConfigured());
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
//================================================================================
|
|
229
|
+
// Subscriber Attributes
|
|
230
|
+
//================================================================================
|
|
231
|
+
|
|
232
|
+
@ReactMethod
|
|
233
|
+
public void setAttributes(ReadableMap attributes) {
|
|
234
|
+
HashMap attributesHashMap = attributes.toHashMap();
|
|
235
|
+
SubscriberAttributesKt.setAttributes(attributesHashMap);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
@ReactMethod
|
|
239
|
+
public void setEmail(String email) {
|
|
240
|
+
SubscriberAttributesKt.setEmail(email);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@ReactMethod
|
|
244
|
+
public void setPhoneNumber(String phoneNumber) {
|
|
245
|
+
SubscriberAttributesKt.setPhoneNumber(phoneNumber);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@ReactMethod
|
|
249
|
+
public void setDisplayName(String displayName) {
|
|
250
|
+
SubscriberAttributesKt.setDisplayName(displayName);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
@ReactMethod
|
|
254
|
+
public void setPushToken(String pushToken) {
|
|
255
|
+
SubscriberAttributesKt.setPushToken(pushToken);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// region Attribution IDs
|
|
259
|
+
|
|
260
|
+
@ReactMethod
|
|
261
|
+
public void collectDeviceIdentifiers() {
|
|
262
|
+
SubscriberAttributesKt.collectDeviceIdentifiers();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
@ReactMethod
|
|
266
|
+
public void setAdjustID(String adjustID) {
|
|
267
|
+
SubscriberAttributesKt.setAdjustID(adjustID);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
@ReactMethod
|
|
271
|
+
public void setAppsflyerID(String appsflyerID) {
|
|
272
|
+
SubscriberAttributesKt.setAppsflyerID(appsflyerID);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
@ReactMethod
|
|
276
|
+
public void setFBAnonymousID(String fbAnonymousID) {
|
|
277
|
+
SubscriberAttributesKt.setFBAnonymousID(fbAnonymousID);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
@ReactMethod
|
|
281
|
+
public void setMparticleID(String mparticleID) {
|
|
282
|
+
SubscriberAttributesKt.setMparticleID(mparticleID);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
@ReactMethod
|
|
286
|
+
public void setOnesignalID(String onesignalID) {
|
|
287
|
+
SubscriberAttributesKt.setOnesignalID(onesignalID);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@ReactMethod
|
|
291
|
+
public void setAirshipChannelID(String airshipChannelID) {
|
|
292
|
+
SubscriberAttributesKt.setAirshipChannelID(airshipChannelID);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// endregion
|
|
296
|
+
|
|
297
|
+
// region Campaign parameters
|
|
298
|
+
|
|
299
|
+
@ReactMethod
|
|
300
|
+
public void setMediaSource(String mediaSource) {
|
|
301
|
+
SubscriberAttributesKt.setMediaSource(mediaSource);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
@ReactMethod
|
|
305
|
+
public void setCampaign(String campaign) {
|
|
306
|
+
SubscriberAttributesKt.setCampaign(campaign);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
@ReactMethod
|
|
310
|
+
public void setAdGroup(String adGroup) {
|
|
311
|
+
SubscriberAttributesKt.setAdGroup(adGroup);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
@ReactMethod
|
|
315
|
+
public void setAd(String ad) {
|
|
316
|
+
SubscriberAttributesKt.setAd(ad);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
@ReactMethod
|
|
320
|
+
public void setKeyword(String keyword) {
|
|
321
|
+
SubscriberAttributesKt.setKeyword(keyword);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
@ReactMethod
|
|
325
|
+
public void setCreative(String creative) {
|
|
326
|
+
SubscriberAttributesKt.setCreative(creative);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
@ReactMethod
|
|
330
|
+
public void canMakePayments(ReadableArray features, final Promise promise) {
|
|
331
|
+
ArrayList<Integer> featureList = new ArrayList<>();
|
|
332
|
+
|
|
333
|
+
if (features != null) {
|
|
334
|
+
for (int i = 0; i < features.size(); i++) {
|
|
335
|
+
featureList.add(features.getInt(i));
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
CommonKt.canMakePayments(reactContext, featureList, new OnResultAny<Boolean>() {
|
|
339
|
+
@Override
|
|
340
|
+
public void onError(@Nullable ErrorContainer errorContainer) {
|
|
341
|
+
promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
|
|
342
|
+
convertMapToWriteableMap(errorContainer.getInfo()));
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
@Override
|
|
346
|
+
public void onReceived(Boolean result) {
|
|
347
|
+
promise.resolve(result);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// endregion
|
|
353
|
+
|
|
354
|
+
//================================================================================
|
|
355
|
+
// Private methods
|
|
356
|
+
//================================================================================
|
|
357
|
+
|
|
358
|
+
@NotNull
|
|
359
|
+
private OnResult getOnResult(final Promise promise) {
|
|
360
|
+
return new OnResult() {
|
|
361
|
+
@Override
|
|
362
|
+
public void onReceived(Map<String, ?> map) {
|
|
363
|
+
promise.resolve(convertMapToWriteableMap(map));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
@Override
|
|
367
|
+
public void onError(ErrorContainer errorContainer) {
|
|
368
|
+
promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
|
|
369
|
+
convertMapToWriteableMap(errorContainer.getInfo()));
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
}
|
|
@@ -12,7 +12,6 @@ export interface PurchasesEntitlementInfo {
|
|
|
12
12
|
readonly isActive: boolean;
|
|
13
13
|
/**
|
|
14
14
|
* True if the underlying subscription is set to renew at the end of the billing period (expirationDate).
|
|
15
|
-
* Will always be True if entitlement is for lifetime access.
|
|
16
15
|
*/
|
|
17
16
|
readonly willRenew: boolean;
|
|
18
17
|
/**
|
|
@@ -74,9 +73,9 @@ export interface PurchasesEntitlementInfos {
|
|
|
74
73
|
[key: string]: PurchasesEntitlementInfo;
|
|
75
74
|
};
|
|
76
75
|
}
|
|
77
|
-
export interface
|
|
76
|
+
export interface CustomerInfo {
|
|
78
77
|
/**
|
|
79
|
-
* Entitlements attached to this
|
|
78
|
+
* Entitlements attached to this customer info
|
|
80
79
|
*/
|
|
81
80
|
readonly entitlements: PurchasesEntitlementInfos;
|
|
82
81
|
/**
|
|
@@ -137,13 +136,13 @@ export interface PurchaserInfo {
|
|
|
137
136
|
* If there are multiple for different platforms, it will point to the device store.
|
|
138
137
|
*/
|
|
139
138
|
readonly managementURL: string | null;
|
|
140
|
-
readonly nonSubscriptionTransactions:
|
|
139
|
+
readonly nonSubscriptionTransactions: PurchasesStoreTransaction[];
|
|
141
140
|
}
|
|
142
141
|
/**
|
|
143
142
|
* List of all non subscription transactions. Use this to fetch the history of
|
|
144
143
|
* non-subscription purchases
|
|
145
144
|
*/
|
|
146
|
-
export interface
|
|
145
|
+
export interface PurchasesStoreTransaction {
|
|
147
146
|
/**
|
|
148
147
|
* RevenueCat Id associated to the transaction.
|
|
149
148
|
*/
|
|
File without changes
|