react-native-purchases 5.0.0-beta.5 → 5.0.0-beta.6

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.
@@ -24,6 +24,6 @@ Pod::Spec.new do |spec|
24
24
  ]
25
25
 
26
26
  spec.dependency "React-Core"
27
- spec.dependency "PurchasesHybridCommon", '4.1.1'
27
+ spec.dependency "PurchasesHybridCommon", '4.1.2'
28
28
  spec.swift_version = '5.0'
29
29
  end
@@ -29,7 +29,7 @@ android {
29
29
  minSdkVersion getExtOrIntegerDefault('minSdkVersion')
30
30
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
31
31
  versionCode 1
32
- versionName '5.0.0-beta.5'
32
+ versionName '5.0.0-beta.6'
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:4.1.1'
124
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:4.1.2'
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
126
  }
package/ios/RNPurchases.m CHANGED
@@ -346,7 +346,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
346
346
  }
347
347
 
348
348
  - (NSString *)platformFlavorVersion {
349
- return @"5.0.0-beta.5";
349
+ return @"5.0.0-beta.6";
350
350
  }
351
351
 
352
352
  @end
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-purchases",
3
3
  "title": "React Native Purchases",
4
- "version": "5.0.0-beta.5",
4
+ "version": "5.0.0-beta.6",
5
5
  "description": "React Native in-app purchases and subscriptions made easy. Supports iOS and Android. ",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -2,7 +2,7 @@
2
2
  <!DOCTYPE html>
3
3
  <html>
4
4
  <head>
5
- <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/5.0.0-beta.5/" />
5
+ <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/5.0.0-beta.6/" />
6
6
  </head>
7
7
  <body>
8
8
  </body>
@@ -1,126 +0,0 @@
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.5'
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.1.1'
125
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
- }
@@ -1,379 +0,0 @@
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.Store;
20
- import com.revenuecat.purchases.common.PlatformInfo;
21
- import com.revenuecat.purchases.hybridcommon.CommonKt;
22
- import com.revenuecat.purchases.hybridcommon.ErrorContainer;
23
- import com.revenuecat.purchases.hybridcommon.OnResult;
24
- import com.revenuecat.purchases.hybridcommon.OnResultAny;
25
- import com.revenuecat.purchases.hybridcommon.OnResultList;
26
- import com.revenuecat.purchases.hybridcommon.SubscriberAttributesKt;
27
- import com.revenuecat.purchases.hybridcommon.mappers.CustomerInfoMapperKt;
28
- import com.revenuecat.purchases.interfaces.UpdatedCustomerInfoListener;
29
-
30
- import org.jetbrains.annotations.NotNull;
31
- import org.json.JSONException;
32
-
33
- import java.util.ArrayList;
34
- import java.util.HashMap;
35
- import java.util.List;
36
- import java.util.Map;
37
-
38
- import kotlin.UninitializedPropertyAccessException;
39
-
40
- import static com.revenuecat.purchases.react.RNPurchasesConverters.convertMapToWriteableMap;
41
-
42
- public class RNPurchasesModule extends ReactContextBaseJavaModule implements UpdatedCustomerInfoListener {
43
-
44
- private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
45
- public static final String PLATFORM_NAME = "react-native";
46
- public static final String PLUGIN_VERSION = "4.6.0";
47
-
48
- private final ReactApplicationContext reactContext;
49
-
50
- @SuppressWarnings("WeakerAccess")
51
- public RNPurchasesModule(ReactApplicationContext reactContext) {
52
- super(reactContext);
53
- this.reactContext = reactContext;
54
- }
55
-
56
- @NonNull
57
- @Override
58
- public String getName() {
59
- return "RNPurchases";
60
- }
61
-
62
- public void onCatalystInstanceDestroy() {
63
- try {
64
- Purchases.getSharedInstance().close();
65
- } catch (UninitializedPropertyAccessException e) {
66
- // there's no instance so all good
67
- }
68
- }
69
-
70
- @ReactMethod
71
- public void addListener(String eventName) {
72
- // Keep: Required for RN built in Event Emitter Calls.
73
- }
74
-
75
- @ReactMethod
76
- public void removeListeners(Integer count) {
77
- // Keep: Required for RN built in Event Emitter Calls.
78
- }
79
-
80
- @ReactMethod
81
- public void setupPurchases(String apiKey, @Nullable String appUserID,
82
- boolean observerMode, @Nullable String userDefaultsSuiteName,
83
- @Nullable Boolean usesStoreKit2IfAvailable, boolean useAmazon) {
84
- PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
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);
91
- }
92
-
93
- @ReactMethod
94
- public void setAllowSharingStoreAccount(boolean allowSharingStoreAccount) {
95
- CommonKt.setAllowSharingAppStoreAccount(allowSharingStoreAccount);
96
- }
97
-
98
- @ReactMethod
99
- public void getOfferings(final Promise promise) {
100
- CommonKt.getOfferings(getOnResult(promise));
101
- }
102
-
103
- @ReactMethod
104
- public void getProductInfo(ReadableArray productIDs, String type, final Promise promise) {
105
- ArrayList<String> productIDList = new ArrayList<>();
106
- for (int i = 0; i < productIDs.size(); i++) {
107
- productIDList.add(productIDs.getString(i));
108
- }
109
- CommonKt.getProductInfo(productIDList, type, new OnResultList() {
110
- @Override
111
- public void onReceived(List<Map<String, ?>> map) {
112
- WritableArray writableArray = Arguments.createArray();
113
- for (Map<String, ?> detail : map) {
114
- writableArray.pushMap(convertMapToWriteableMap(detail));
115
- }
116
- promise.resolve(writableArray);
117
- }
118
-
119
- @Override
120
- public void onError(ErrorContainer errorContainer) {
121
- promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
122
- convertMapToWriteableMap(errorContainer.getInfo()));
123
- }
124
- });
125
- }
126
-
127
- @ReactMethod
128
- public void purchaseProduct(final String productIdentifier,
129
- @Nullable final ReadableMap upgradeInfo,
130
- final String type,
131
- @Nullable final String discountTimestamp,
132
- final Promise promise) {
133
- CommonKt.purchaseProduct(
134
- getCurrentActivity(),
135
- productIdentifier,
136
- upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null,
137
- upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null,
138
- type,
139
- getOnResult(promise));
140
- }
141
-
142
- @ReactMethod
143
- public void purchasePackage(final String packageIdentifier,
144
- final String offeringIdentifier,
145
- @Nullable final ReadableMap upgradeInfo,
146
- @Nullable final String discountTimestamp,
147
- final Promise promise) {
148
- CommonKt.purchasePackage(
149
- getCurrentActivity(),
150
- packageIdentifier,
151
- offeringIdentifier,
152
- upgradeInfo != null && upgradeInfo.hasKey("oldSKU") ? upgradeInfo.getString("oldSKU") : null,
153
- upgradeInfo != null && upgradeInfo.hasKey("prorationMode") ? upgradeInfo.getInt("prorationMode") : null,
154
- getOnResult(promise));
155
- }
156
-
157
- @ReactMethod
158
- public void getAppUserID(final Promise promise) {
159
- promise.resolve(CommonKt.getAppUserID());
160
- }
161
-
162
- @ReactMethod
163
- public void restorePurchases(final Promise promise) {
164
- CommonKt.restorePurchases(getOnResult(promise));
165
- }
166
-
167
- @ReactMethod
168
- public void logOut(final Promise promise) {
169
- CommonKt.logOut(getOnResult(promise));
170
- }
171
-
172
- @ReactMethod
173
- public void logIn(String appUserID, final Promise promise) {
174
- CommonKt.logIn(appUserID, getOnResult(promise));
175
- }
176
-
177
- @ReactMethod
178
- public void setDebugLogsEnabled(boolean enabled) {
179
- CommonKt.setDebugLogsEnabled(enabled);
180
- }
181
-
182
- @ReactMethod
183
- public void getCustomerInfo(final Promise promise) {
184
- CommonKt.getCustomerInfo(getOnResult(promise));
185
- }
186
-
187
- @ReactMethod
188
- public void setFinishTransactions(boolean enabled) {
189
- CommonKt.setFinishTransactions(enabled);
190
- }
191
-
192
- @ReactMethod
193
- public void syncPurchases() {
194
- CommonKt.syncPurchases();
195
- }
196
-
197
- @ReactMethod
198
- public void isAnonymous(final Promise promise) {
199
- promise.resolve(CommonKt.isAnonymous());
200
- }
201
-
202
- @ReactMethod
203
- public void checkTrialOrIntroductoryPriceEligibility(ReadableArray productIDs, final Promise promise) {
204
- ArrayList<String> productIDList = new ArrayList<>();
205
- for (int i = 0; i < productIDs.size(); i++) {
206
- productIDList.add(productIDs.getString(i));
207
- }
208
- promise.resolve(convertMapToWriteableMap(CommonKt.checkTrialOrIntroductoryPriceEligibility(productIDList)));
209
- }
210
-
211
- @Override
212
- public void onReceived(@NonNull CustomerInfo customerInfo) {
213
- reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
214
- .emit(RNPurchasesModule.CUSTOMER_INFO_UPDATED,
215
- convertMapToWriteableMap(CustomerInfoMapperKt.map(customerInfo)));
216
- }
217
-
218
- @ReactMethod
219
- public void invalidateCustomerInfoCache() {
220
- CommonKt.invalidateCustomerInfoCache();
221
- }
222
-
223
- @ReactMethod
224
- public void setProxyURLString(String proxyURLString) {
225
- CommonKt.setProxyURLString(proxyURLString);
226
- }
227
-
228
- @ReactMethod
229
- public void isConfigured(Promise promise) {
230
- promise.resolve(Purchases.isConfigured());
231
- }
232
-
233
- //================================================================================
234
- // Subscriber Attributes
235
- //================================================================================
236
-
237
- @ReactMethod
238
- public void setAttributes(ReadableMap attributes) {
239
- HashMap attributesHashMap = attributes.toHashMap();
240
- SubscriberAttributesKt.setAttributes(attributesHashMap);
241
- }
242
-
243
- @ReactMethod
244
- public void setEmail(String email) {
245
- SubscriberAttributesKt.setEmail(email);
246
- }
247
-
248
- @ReactMethod
249
- public void setPhoneNumber(String phoneNumber) {
250
- SubscriberAttributesKt.setPhoneNumber(phoneNumber);
251
- }
252
-
253
- @ReactMethod
254
- public void setDisplayName(String displayName) {
255
- SubscriberAttributesKt.setDisplayName(displayName);
256
- }
257
-
258
- @ReactMethod
259
- public void setPushToken(String pushToken) {
260
- SubscriberAttributesKt.setPushToken(pushToken);
261
- }
262
-
263
- // region Attribution IDs
264
-
265
- @ReactMethod
266
- public void collectDeviceIdentifiers() {
267
- SubscriberAttributesKt.collectDeviceIdentifiers();
268
- }
269
-
270
- @ReactMethod
271
- public void setAdjustID(String adjustID) {
272
- SubscriberAttributesKt.setAdjustID(adjustID);
273
- }
274
-
275
- @ReactMethod
276
- public void setAppsflyerID(String appsflyerID) {
277
- SubscriberAttributesKt.setAppsflyerID(appsflyerID);
278
- }
279
-
280
- @ReactMethod
281
- public void setFBAnonymousID(String fbAnonymousID) {
282
- SubscriberAttributesKt.setFBAnonymousID(fbAnonymousID);
283
- }
284
-
285
- @ReactMethod
286
- public void setMparticleID(String mparticleID) {
287
- SubscriberAttributesKt.setMparticleID(mparticleID);
288
- }
289
-
290
- @ReactMethod
291
- public void setOnesignalID(String onesignalID) {
292
- SubscriberAttributesKt.setOnesignalID(onesignalID);
293
- }
294
-
295
- @ReactMethod
296
- public void setAirshipChannelID(String airshipChannelID) {
297
- SubscriberAttributesKt.setAirshipChannelID(airshipChannelID);
298
- }
299
-
300
- // endregion
301
-
302
- // region Campaign parameters
303
-
304
- @ReactMethod
305
- public void setMediaSource(String mediaSource) {
306
- SubscriberAttributesKt.setMediaSource(mediaSource);
307
- }
308
-
309
- @ReactMethod
310
- public void setCampaign(String campaign) {
311
- SubscriberAttributesKt.setCampaign(campaign);
312
- }
313
-
314
- @ReactMethod
315
- public void setAdGroup(String adGroup) {
316
- SubscriberAttributesKt.setAdGroup(adGroup);
317
- }
318
-
319
- @ReactMethod
320
- public void setAd(String ad) {
321
- SubscriberAttributesKt.setAd(ad);
322
- }
323
-
324
- @ReactMethod
325
- public void setKeyword(String keyword) {
326
- SubscriberAttributesKt.setKeyword(keyword);
327
- }
328
-
329
- @ReactMethod
330
- public void setCreative(String creative) {
331
- SubscriberAttributesKt.setCreative(creative);
332
- }
333
-
334
- @ReactMethod
335
- public void canMakePayments(ReadableArray features, final Promise promise) {
336
- ArrayList<Integer> featureList = new ArrayList<>();
337
-
338
- if (features != null) {
339
- for (int i = 0; i < features.size(); i++) {
340
- featureList.add(features.getInt(i));
341
- }
342
- }
343
- CommonKt.canMakePayments(reactContext, featureList, new OnResultAny<Boolean>() {
344
- @Override
345
- public void onError(@Nullable ErrorContainer errorContainer) {
346
- promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
347
- convertMapToWriteableMap(errorContainer.getInfo()));
348
- }
349
-
350
- @Override
351
- public void onReceived(Boolean result) {
352
- promise.resolve(result);
353
- }
354
- });
355
- }
356
-
357
- // endregion
358
-
359
- //================================================================================
360
- // Private methods
361
- //================================================================================
362
-
363
- @NotNull
364
- private OnResult getOnResult(final Promise promise) {
365
- return new OnResult() {
366
- @Override
367
- public void onReceived(Map<String, ?> map) {
368
- promise.resolve(convertMapToWriteableMap(map));
369
- }
370
-
371
- @Override
372
- public void onError(ErrorContainer errorContainer) {
373
- promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
374
- convertMapToWriteableMap(errorContainer.getInfo()));
375
- }
376
- };
377
- }
378
-
379
- }
@@ -1,352 +0,0 @@
1
-
2
- //
3
- // Created by RevenueCat.
4
- // Copyright © 2019 RevenueCat. All rights reserved.
5
- //
6
-
7
- #import "RNPurchases.h"
8
-
9
- @import StoreKit;
10
-
11
- typedef void (^PurchaseCompletedBlock)(RCStoreTransaction *, RCCustomerInfo *, NSError *, BOOL);
12
- typedef void (^StartPurchaseBlock)(PurchaseCompletedBlock);
13
-
14
- @interface RNPurchases () <RCPurchasesDelegate>
15
-
16
- @property (nonatomic, retain) NSMutableArray<StartPurchaseBlock> *defermentBlocks;
17
-
18
- @end
19
-
20
-
21
- NSString *RNPurchasesCustomerInfoUpdatedEvent = @"Purchases-CustomerInfoUpdated";
22
- NSString *RNPurchasesShouldPurchasePromoProductEvent = @"Purchases-ShouldPurchasePromoProduct";
23
-
24
-
25
- @implementation RNPurchases
26
-
27
- - (dispatch_queue_t)methodQueue {
28
- return dispatch_get_main_queue();
29
- }
30
-
31
- - (NSArray<NSString *> *)supportedEvents {
32
- return @[RNPurchasesCustomerInfoUpdatedEvent, RNPurchasesShouldPurchasePromoProductEvent];
33
- }
34
-
35
- RCT_EXPORT_MODULE();
36
-
37
- RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
38
- appUserID:(nullable NSString *)appUserID
39
- observerMode:(BOOL)observerMode
40
- userDefaultsSuiteName:(nullable NSString *)userDefaultsSuiteName
41
- usesStoreKit2IfAvailable:(BOOL)usesStoreKit2IfAvailable
42
- useAmazon:(BOOL)useAmazon) {
43
- RCPurchases *purchases = [RCPurchases configureWithAPIKey:apiKey
44
- appUserID:appUserID
45
- observerMode:observerMode
46
- userDefaultsSuiteName:userDefaultsSuiteName
47
- platformFlavor:self.platformFlavor
48
- platformFlavorVersion:self.platformFlavorVersion
49
- usesStoreKit2IfAvailable:usesStoreKit2IfAvailable
50
- dangerousSettings:nil];
51
- purchases.delegate = self;
52
- }
53
-
54
- RCT_EXPORT_METHOD(setAllowSharingStoreAccount:(BOOL)allowSharingStoreAccount) {
55
- #pragma GCC diagnostic push
56
- #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
57
- [RCCommonFunctionality setAllowSharingStoreAccount:allowSharingStoreAccount];
58
- #pragma GCC diagnostic pop
59
- }
60
-
61
- RCT_EXPORT_METHOD(setFinishTransactions:(BOOL)finishTransactions) {
62
- [RCCommonFunctionality setFinishTransactions:finishTransactions];
63
- }
64
-
65
- RCT_REMAP_METHOD(getOfferings,
66
- getOfferingsWithResolve:(RCTPromiseResolveBlock)resolve
67
- reject:(RCTPromiseRejectBlock)reject) {
68
- [RCCommonFunctionality getOfferingsWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve
69
- reject:reject]];
70
- }
71
-
72
- RCT_EXPORT_METHOD(getProductInfo:(NSArray *)products
73
- type:(NSString *)type
74
- resolve:(RCTPromiseResolveBlock)resolve
75
- reject:(RCTPromiseRejectBlock)reject) {
76
- [RCCommonFunctionality getProductInfo:products completionBlock:^(NSArray<NSDictionary *> *productObjects) {
77
- resolve(productObjects);
78
- }];
79
- }
80
-
81
- RCT_REMAP_METHOD(purchaseProduct,
82
- purchaseProduct:(NSString *)productIdentifier
83
- upgradeInfo:(NSDictionary *)upgradeInfo
84
- type:(NSString *)type
85
- signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
86
- resolve:(RCTPromiseResolveBlock)resolve
87
- reject:(RCTPromiseRejectBlock)reject) {
88
- [RCCommonFunctionality purchaseProduct:productIdentifier
89
- signedDiscountTimestamp:signedDiscountTimestamp
90
- completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
91
- }
92
-
93
-
94
- RCT_REMAP_METHOD(purchasePackage,
95
- purchasePackage:(NSString *)packageIdentifier
96
- offeringIdentifier:(NSString *)offeringIdentifier
97
- upgradeInfo:(NSDictionary *)upgradeInfo
98
- signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
99
- resolve:(RCTPromiseResolveBlock)resolve
100
- reject:(RCTPromiseRejectBlock)reject) {
101
- [RCCommonFunctionality purchasePackage:packageIdentifier
102
- offering:offeringIdentifier
103
- signedDiscountTimestamp:signedDiscountTimestamp
104
- completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
105
- }
106
-
107
- RCT_REMAP_METHOD(restorePurchases,
108
- restorePurchasesWithResolve:(RCTPromiseResolveBlock)resolve
109
- reject:(RCTPromiseRejectBlock)reject) {
110
- [RCCommonFunctionality restorePurchasesWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve
111
- reject:reject]];
112
- }
113
-
114
- RCT_EXPORT_METHOD(syncPurchases) {
115
- [RCCommonFunctionality syncPurchasesWithCompletionBlock:nil];
116
- }
117
-
118
- RCT_REMAP_METHOD(getAppUserID,
119
- getAppUserIDWithResolve:(RCTPromiseResolveBlock)resolve
120
- reject:(RCTPromiseRejectBlock)reject) {
121
- resolve([RCCommonFunctionality appUserID]);
122
- }
123
-
124
- RCT_EXPORT_METHOD(logIn:(nonnull NSString *)appUserID
125
- resolve:(RCTPromiseResolveBlock)resolve
126
- reject:(RCTPromiseRejectBlock)reject) {
127
- [RCCommonFunctionality logInWithAppUserID:appUserID
128
- completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
129
- }
130
-
131
- RCT_REMAP_METHOD(logOut,
132
- logOutWithResolve:(RCTPromiseResolveBlock)resolve
133
- reject:(RCTPromiseRejectBlock)reject) {
134
- [RCCommonFunctionality logOutWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
135
- }
136
-
137
- RCT_REMAP_METHOD(setDebugLogsEnabled,
138
- debugLogsEnabled:(BOOL)enabled) {
139
- [RCCommonFunctionality setDebugLogsEnabled:enabled];
140
- }
141
-
142
- RCT_EXPORT_METHOD(setSimulatesAskToBuyInSandbox:(BOOL)simulatesAskToBuyInSandbox)
143
- {
144
- [RCCommonFunctionality setSimulatesAskToBuyInSandbox:simulatesAskToBuyInSandbox];
145
- }
146
-
147
- RCT_REMAP_METHOD(getCustomerInfo,
148
- customerInfoWithResolve:(RCTPromiseResolveBlock)resolve
149
- reject:(RCTPromiseRejectBlock)reject) {
150
- [RCCommonFunctionality getCustomerInfoWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
151
- }
152
-
153
- RCT_EXPORT_METHOD(setAutomaticAppleSearchAdsAttributionCollection:(BOOL)automaticAppleSearchAdsAttributionCollection)
154
- {
155
- [RCCommonFunctionality setAutomaticAppleSearchAdsAttributionCollection:automaticAppleSearchAdsAttributionCollection];
156
- }
157
-
158
- RCT_EXPORT_METHOD(enableAdServicesAttributionTokenCollection)
159
- {
160
- if (@available(iOS 14.3, macOS 11.1, macCatalyst 14.3, *)) {
161
- [RCCommonFunctionality enableAdServicesAttributionTokenCollection];
162
- } else {
163
- NSLog(@"[Purchases] Warning: tried to enable AdServices attribution token collection, but it's only available on iOS 14.3 or greater or macOS 11.1 or greater.");
164
- }
165
- }
166
-
167
- RCT_REMAP_METHOD(isAnonymous,
168
- isAnonymousWithResolve:(RCTPromiseResolveBlock)resolve
169
- reject:(RCTPromiseRejectBlock)reject) {
170
- resolve(@([RCCommonFunctionality isAnonymous]));
171
- }
172
-
173
- RCT_EXPORT_METHOD(makeDeferredPurchase:(nonnull NSNumber *)callbackID
174
- resolve:(RCTPromiseResolveBlock)resolve
175
- reject:(RCTPromiseRejectBlock)reject) {
176
- StartPurchaseBlock defermentBlock = [self.defermentBlocks objectAtIndex:[callbackID integerValue]];
177
- [RCCommonFunctionality makeDeferredPurchase:defermentBlock
178
- completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
179
- }
180
-
181
- RCT_EXPORT_METHOD(checkTrialOrIntroductoryPriceEligibility:(NSArray *)products
182
- resolve:(RCTPromiseResolveBlock)resolve
183
- reject:(RCTPromiseRejectBlock)reject) {
184
- [RCCommonFunctionality checkTrialOrIntroductoryPriceEligibility:products
185
- completionBlock:^(NSDictionary<NSString *,RCIntroEligibility *> * _Nonnull responseDictionary) {
186
- resolve([NSDictionary dictionaryWithDictionary:responseDictionary]);
187
- }];
188
- }
189
-
190
- RCT_EXPORT_METHOD(invalidateCustomerInfoCache) {
191
- [RCCommonFunctionality invalidateCustomerInfoCache];
192
- }
193
-
194
- RCT_REMAP_METHOD(getPromotionalOffer,
195
- getPromotionalOfferForProductIdentifier:(NSString *)productIdentifier
196
- discount:(NSString *)discount
197
- resolve:(RCTPromiseResolveBlock)resolve
198
- reject:(RCTPromiseRejectBlock)reject) {
199
- [RCCommonFunctionality promotionalOfferForProductIdentifier:productIdentifier
200
- discount:discount
201
- completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
202
- }
203
-
204
- RCT_EXPORT_METHOD(presentCodeRedemptionSheet) {
205
- if (@available(iOS 14.0, *)) {
206
- [RCCommonFunctionality presentCodeRedemptionSheet];
207
- } else {
208
- NSLog(@"[Purchases] Warning: tried to present codeRedemptionSheet, but it's only available on iOS 14.0 or greater.");
209
- }
210
- }
211
-
212
- #pragma mark - Subscriber Attributes
213
-
214
- RCT_EXPORT_METHOD(setProxyURLString:(nullable NSString *)proxyURLString) {
215
- [RCCommonFunctionality setProxyURLString:proxyURLString];
216
- }
217
-
218
- RCT_EXPORT_METHOD(setAttributes:(NSDictionary *)attributes) {
219
- [RCCommonFunctionality setAttributes:attributes];
220
- }
221
-
222
- RCT_EXPORT_METHOD(setEmail:(NSString *)email) {
223
- [RCCommonFunctionality setEmail:email];
224
- }
225
-
226
- RCT_EXPORT_METHOD(setPhoneNumber:(NSString *)phoneNumber) {
227
- [RCCommonFunctionality setPhoneNumber:phoneNumber];
228
- }
229
-
230
- RCT_EXPORT_METHOD(setDisplayName:(NSString *)displayName) {
231
- [RCCommonFunctionality setDisplayName:displayName];
232
- }
233
-
234
- RCT_EXPORT_METHOD(setPushToken:(NSString *)pushToken) {
235
- [RCCommonFunctionality setPushToken:pushToken];
236
- }
237
-
238
- # pragma mark Attribution IDs
239
-
240
- RCT_EXPORT_METHOD(collectDeviceIdentifiers) {
241
- [RCCommonFunctionality collectDeviceIdentifiers];
242
- }
243
-
244
- RCT_EXPORT_METHOD(setAdjustID:(NSString *)adjustID) {
245
- [RCCommonFunctionality setAdjustID:adjustID];
246
- }
247
-
248
- RCT_EXPORT_METHOD(setAppsflyerID:(NSString *)appsflyerID) {
249
- [RCCommonFunctionality setAppsflyerID:appsflyerID];
250
- }
251
-
252
- RCT_EXPORT_METHOD(setFBAnonymousID:(NSString *)fbAnonymousID) {
253
- [RCCommonFunctionality setFBAnonymousID:fbAnonymousID];
254
- }
255
-
256
- RCT_EXPORT_METHOD(setMparticleID:(NSString *)mparticleID) {
257
- [RCCommonFunctionality setMparticleID:mparticleID];
258
- }
259
-
260
- RCT_EXPORT_METHOD(setOnesignalID:(NSString *)onesignalID) {
261
- [RCCommonFunctionality setOnesignalID:onesignalID];
262
- }
263
-
264
- RCT_EXPORT_METHOD(setAirshipChannelID:(NSString *)airshipChannelID) {
265
- [RCCommonFunctionality setAirshipChannelID:airshipChannelID];
266
- }
267
-
268
- # pragma mark Campaign parameters
269
-
270
- RCT_EXPORT_METHOD(setMediaSource:(NSString *)mediaSource) {
271
- [RCCommonFunctionality setMediaSource:mediaSource];
272
- }
273
-
274
- RCT_EXPORT_METHOD(setCampaign:(NSString *)campaign) {
275
- [RCCommonFunctionality setCampaign:campaign];
276
- }
277
-
278
- RCT_EXPORT_METHOD(setAdGroup:(NSString *)adGroup) {
279
- [RCCommonFunctionality setAdGroup:adGroup];
280
- }
281
-
282
- RCT_EXPORT_METHOD(setAd:(NSString *)ad) {
283
- [RCCommonFunctionality setAd:ad];
284
- }
285
-
286
- RCT_EXPORT_METHOD(setKeyword:(NSString *)keyword) {
287
- [RCCommonFunctionality setKeyword:keyword];
288
- }
289
-
290
- RCT_EXPORT_METHOD(setCreative:(NSString *)creative) {
291
- [RCCommonFunctionality setCreative:creative];
292
- }
293
-
294
- RCT_REMAP_METHOD(canMakePayments,
295
- canMakePaymentsWithFeatures:(NSArray<NSNumber *> *)features
296
- resolve:(RCTPromiseResolveBlock)resolve
297
- reject:(RCTPromiseRejectBlock)reject) {
298
- resolve(@([RCCommonFunctionality canMakePaymentsWithFeatures:features]));
299
- }
300
-
301
- RCT_REMAP_METHOD(isConfigured,
302
- isConfiguredWithResolve:(RCTPromiseResolveBlock)resolve
303
- reject:(RCTPromiseRejectBlock)reject) {
304
- resolve(@(RCPurchases.isConfigured));
305
- }
306
-
307
- #pragma mark -
308
- #pragma mark Delegate Methods
309
- - (void)purchases:(RCPurchases *)purchases didReceiveUpdatedCustomerInfo:(RCCustomerInfo *)customerInfo {
310
- [self sendEventWithName:RNPurchasesCustomerInfoUpdatedEvent body:customerInfo.dictionary];
311
- }
312
-
313
- - (void)purchases:(RCPurchases *)purchases
314
- readyForPromotedProduct:(RCStoreProduct *)product
315
- purchase:(void (^)(void (^ _Nonnull)(RCStoreTransaction * _Nullable, RCCustomerInfo * _Nullable, NSError * _Nullable, BOOL)))startPurchase {
316
- if (!self.defermentBlocks) {
317
- self.defermentBlocks = [NSMutableArray array];
318
- }
319
- [self.defermentBlocks addObject:startPurchase];
320
- NSInteger position = [self.defermentBlocks count] - 1;
321
- [self sendEventWithName:RNPurchasesShouldPurchasePromoProductEvent body:@{@"callbackID": @(position)}];
322
- }
323
-
324
- #pragma mark -
325
- #pragma mark Helper Methods
326
-
327
- - (void)rejectPromiseWithBlock:(RCTPromiseRejectBlock)reject error:(NSError *)error {
328
- reject([NSString stringWithFormat: @"%ld", (long)error.code], error.localizedDescription, error);
329
- }
330
-
331
- - (void (^)(NSDictionary *, RCErrorContainer *))getResponseCompletionBlockWithResolve:(RCTPromiseResolveBlock)resolve
332
- reject:(RCTPromiseRejectBlock)reject {
333
- return ^(NSDictionary *_Nullable responseDictionary, RCErrorContainer *_Nullable error) {
334
- if (error) {
335
- reject([NSString stringWithFormat:@"%ld", (long) error.code], error.message, error.error);
336
- } else if (responseDictionary) {
337
- resolve([NSDictionary dictionaryWithDictionary:responseDictionary]);
338
- } else {
339
- resolve(nil);
340
- }
341
- };
342
- }
343
-
344
- - (NSString *)platformFlavor {
345
- return @"react-native";
346
- }
347
-
348
- - (NSString *)platformFlavorVersion {
349
- return @"5.0.0-beta.5";
350
- }
351
-
352
- @end
@@ -1,19 +0,0 @@
1
- const {exec} = require("child_process");
2
- const os = require("os");
3
-
4
- if (os.type() === "Linux") {
5
- console.log("Skipping iOS Dependencies");
6
- } else if (os.type() === "Darwin") {
7
- const downloadProcess = exec(
8
- "./scripts/download-purchases-framework.sh 3.14.1"
9
- );
10
- downloadProcess.stdout.pipe(process.stdout);
11
- const downloadProcessCommon = exec(
12
- "./scripts/download-purchases-common.sh 1.11.1"
13
- );
14
- downloadProcessCommon.stdout.pipe(process.stdout);
15
- } else if (os.type() === "Windows_NT") {
16
- console.log("Skipping iOS Dependencies");
17
- } else {
18
- throw new Error(`Unsupported OS found: ${os.type()}`);
19
- }
@@ -1,9 +0,0 @@
1
- <!-- This file is used to redirect visitors to the latest version of the docs -->
2
- <!DOCTYPE html>
3
- <html>
4
- <head>
5
- <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/5.0.0-beta.5/" />
6
- </head>
7
- <body>
8
- </body>
9
- </html>