react-native-purchases 4.6.1 → 4.6.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.
@@ -29,7 +29,7 @@ android {
29
29
  minSdkVersion getExtOrIntegerDefault('minSdkVersion')
30
30
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
31
31
  versionCode 1
32
- versionName '4.6.1'
32
+ versionName '4.6.2'
33
33
  }
34
34
 
35
35
  buildTypes {
@@ -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.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:2.0.1'
125
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
+ }
@@ -1,5 +1,5 @@
1
1
  android.useAndroidX=true
2
- Purchases_kotlinVersion=1.4.0
2
+ Purchases_kotlinVersion=1.6.21
3
3
  Purchases_compileSdkVersion=28
4
4
  Purchases_targetSdkVersion=28
5
5
  Purchases_minSdkVersion=16
@@ -43,7 +43,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
43
43
 
44
44
  private static final String PURCHASER_INFO_UPDATED = "Purchases-PurchaserInfoUpdated";
45
45
  public static final String PLATFORM_NAME = "react-native";
46
- public static final String PLUGIN_VERSION = "4.6.1";
46
+ public static final String PLUGIN_VERSION = "4.6.2";
47
47
 
48
48
  private final ReactApplicationContext reactContext;
49
49
 
@@ -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
  /**
package/ios/RNPurchases.m CHANGED
@@ -369,7 +369,7 @@ shouldPurchasePromoProduct:(SKProduct *)product
369
369
  }
370
370
 
371
371
  - (NSString *)platformFlavorVersion {
372
- return @"4.6.1";
372
+ return @"4.6.2";
373
373
  }
374
374
 
375
375
  @end
@@ -0,0 +1,375 @@
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
+
12
+ @interface RNPurchases () <RCPurchasesDelegate>
13
+
14
+ @property (nonatomic, retain) NSMutableArray<RCDeferredPromotionalPurchaseBlock> *defermentBlocks;
15
+
16
+ @end
17
+
18
+
19
+ NSString *RNPurchasesPurchaserInfoUpdatedEvent = @"Purchases-PurchaserInfoUpdated";
20
+ NSString *RNPurchasesShouldPurchasePromoProductEvent = @"Purchases-ShouldPurchasePromoProduct";
21
+
22
+
23
+ @implementation RNPurchases
24
+
25
+ - (dispatch_queue_t)methodQueue {
26
+ return dispatch_get_main_queue();
27
+ }
28
+
29
+ - (NSArray<NSString *> *)supportedEvents {
30
+ return @[RNPurchasesPurchaserInfoUpdatedEvent, RNPurchasesShouldPurchasePromoProductEvent];
31
+ }
32
+
33
+ RCT_EXPORT_MODULE();
34
+
35
+ RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
36
+ appUserID:(nullable NSString *)appUserID
37
+ observerMode:(BOOL)observerMode
38
+ userDefaultsSuiteName:(nullable NSString *)userDefaultsSuiteName) {
39
+ [RCPurchases configureWithAPIKey:apiKey
40
+ appUserID:appUserID
41
+ observerMode:observerMode
42
+ userDefaultsSuiteName:userDefaultsSuiteName
43
+ platformFlavor:self.platformFlavor
44
+ platformFlavorVersion:self.platformFlavorVersion
45
+ dangerousSettings:nil];
46
+ RCPurchases.sharedPurchases.delegate = self;
47
+ [RCCommonFunctionality configure];
48
+ }
49
+
50
+ RCT_EXPORT_METHOD(setAllowSharingStoreAccount:(BOOL)allowSharingStoreAccount) {
51
+ #pragma GCC diagnostic push
52
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
53
+ [RCCommonFunctionality setAllowSharingStoreAccount:allowSharingStoreAccount];
54
+ #pragma GCC diagnostic pop
55
+ }
56
+
57
+ RCT_EXPORT_METHOD(setFinishTransactions:(BOOL)finishTransactions) {
58
+ [RCCommonFunctionality setFinishTransactions:finishTransactions];
59
+ }
60
+
61
+ RCT_EXPORT_METHOD(addAttributionData:(NSDictionary *)data
62
+ forNetwork:(NSInteger)network
63
+ forNetworkUserId:(nullable NSString *)networkUserId) {
64
+ #pragma GCC diagnostic push
65
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
66
+ [RCCommonFunctionality addAttributionData:data network:network networkUserId:networkUserId];
67
+ #pragma GCC diagnostic pop
68
+ }
69
+
70
+ RCT_REMAP_METHOD(getOfferings,
71
+ getOfferingsWithResolve:(RCTPromiseResolveBlock)resolve
72
+ reject:(RCTPromiseRejectBlock)reject) {
73
+ [RCCommonFunctionality getOfferingsWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve
74
+ reject:reject]];
75
+ }
76
+
77
+ RCT_EXPORT_METHOD(getProductInfo:(NSArray *)products
78
+ type:(NSString *)type
79
+ resolve:(RCTPromiseResolveBlock)resolve
80
+ reject:(RCTPromiseRejectBlock)reject) {
81
+ [RCCommonFunctionality getProductInfo:products completionBlock:^(NSArray<NSDictionary *> *productObjects) {
82
+ resolve(productObjects);
83
+ }];
84
+ }
85
+
86
+ RCT_REMAP_METHOD(purchaseProduct,
87
+ purchaseProduct:(NSString *)productIdentifier
88
+ upgradeInfo:(NSDictionary *)upgradeInfo
89
+ type:(NSString *)type
90
+ signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
91
+ resolve:(RCTPromiseResolveBlock)resolve
92
+ reject:(RCTPromiseRejectBlock)reject) {
93
+ [RCCommonFunctionality purchaseProduct:productIdentifier
94
+ signedDiscountTimestamp:signedDiscountTimestamp
95
+ completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
96
+ }
97
+
98
+
99
+ RCT_REMAP_METHOD(purchasePackage,
100
+ purchasePackage:(NSString *)packageIdentifier
101
+ offeringIdentifier:(NSString *)offeringIdentifier
102
+ upgradeInfo:(NSDictionary *)upgradeInfo
103
+ signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
104
+ resolve:(RCTPromiseResolveBlock)resolve
105
+ reject:(RCTPromiseRejectBlock)reject) {
106
+ [RCCommonFunctionality purchasePackage:packageIdentifier
107
+ offering:offeringIdentifier
108
+ signedDiscountTimestamp:signedDiscountTimestamp
109
+ completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
110
+ }
111
+
112
+ RCT_REMAP_METHOD(restoreTransactions,
113
+ restoreTransactionsWithResolve:(RCTPromiseResolveBlock)resolve
114
+ reject:(RCTPromiseRejectBlock)reject) {
115
+ [RCCommonFunctionality restoreTransactionsWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve
116
+ reject:reject]];
117
+ }
118
+
119
+ RCT_EXPORT_METHOD(syncPurchases) {
120
+ [RCCommonFunctionality syncPurchasesWithCompletionBlock:nil];
121
+ }
122
+
123
+ RCT_REMAP_METHOD(getAppUserID,
124
+ getAppUserIDWithResolve:(RCTPromiseResolveBlock)resolve
125
+ reject:(RCTPromiseRejectBlock)reject) {
126
+ resolve([RCCommonFunctionality appUserID]);
127
+ }
128
+
129
+ RCT_EXPORT_METHOD(createAlias:(nullable NSString *)newAppUserID
130
+ resolve:(RCTPromiseResolveBlock)resolve
131
+ reject:(RCTPromiseRejectBlock)reject) {
132
+ [RCCommonFunctionality createAlias:newAppUserID
133
+ completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
134
+ }
135
+
136
+ RCT_EXPORT_METHOD(logIn:(nonnull NSString *)appUserID
137
+ resolve:(RCTPromiseResolveBlock)resolve
138
+ reject:(RCTPromiseRejectBlock)reject) {
139
+ [RCCommonFunctionality logInWithAppUserID:appUserID
140
+ completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
141
+ }
142
+
143
+ RCT_REMAP_METHOD(logOut,
144
+ logOutWithResolve:(RCTPromiseResolveBlock)resolve
145
+ reject:(RCTPromiseRejectBlock)reject) {
146
+ [RCCommonFunctionality logOutWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
147
+ }
148
+
149
+ RCT_EXPORT_METHOD(identify:(nullable NSString *)appUserID
150
+ resolve:(RCTPromiseResolveBlock)resolve
151
+ reject:(RCTPromiseRejectBlock)reject) {
152
+ #pragma GCC diagnostic push
153
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
154
+ [RCCommonFunctionality identify:appUserID
155
+ completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
156
+ #pragma GCC diagnostic pop
157
+ }
158
+
159
+ RCT_REMAP_METHOD(reset,
160
+ resetWithResolve:(RCTPromiseResolveBlock)resolve
161
+ reject:(RCTPromiseRejectBlock)reject) {
162
+ #pragma GCC diagnostic push
163
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
164
+ [RCCommonFunctionality resetWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
165
+ #pragma GCC diagnostic pop
166
+ }
167
+
168
+ RCT_REMAP_METHOD(setDebugLogsEnabled,
169
+ debugLogsEnabled:(BOOL)enabled) {
170
+ [RCCommonFunctionality setDebugLogsEnabled:enabled];
171
+ }
172
+
173
+ RCT_EXPORT_METHOD(setSimulatesAskToBuyInSandbox:(BOOL)simulatesAskToBuyInSandbox)
174
+ {
175
+ [RCCommonFunctionality setSimulatesAskToBuyInSandbox:simulatesAskToBuyInSandbox];
176
+ }
177
+
178
+ RCT_REMAP_METHOD(getPurchaserInfo,
179
+ purchaserInfoWithResolve:(RCTPromiseResolveBlock)resolve
180
+ reject:(RCTPromiseRejectBlock)reject) {
181
+ [RCCommonFunctionality getPurchaserInfoWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
182
+ }
183
+
184
+ RCT_EXPORT_METHOD(setAutomaticAppleSearchAdsAttributionCollection:(BOOL)automaticAppleSearchAdsAttributionCollection)
185
+ {
186
+ [RCCommonFunctionality setAutomaticAppleSearchAdsAttributionCollection:automaticAppleSearchAdsAttributionCollection];
187
+ }
188
+
189
+ RCT_REMAP_METHOD(isAnonymous,
190
+ isAnonymousWithResolve:(RCTPromiseResolveBlock)resolve
191
+ reject:(RCTPromiseRejectBlock)reject) {
192
+ resolve(@([RCCommonFunctionality isAnonymous]));
193
+ }
194
+
195
+ RCT_EXPORT_METHOD(makeDeferredPurchase:(nonnull NSNumber *)callbackID
196
+ resolve:(RCTPromiseResolveBlock)resolve
197
+ reject:(RCTPromiseRejectBlock)reject) {
198
+ RCDeferredPromotionalPurchaseBlock defermentBlock = [self.defermentBlocks objectAtIndex:[callbackID integerValue]];
199
+ [RCCommonFunctionality makeDeferredPurchase:defermentBlock
200
+ completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
201
+ }
202
+
203
+ RCT_EXPORT_METHOD(checkTrialOrIntroductoryPriceEligibility:(NSArray *)products
204
+ resolve:(RCTPromiseResolveBlock)resolve
205
+ reject:(RCTPromiseRejectBlock)reject) {
206
+ [RCCommonFunctionality checkTrialOrIntroductoryPriceEligibility:products
207
+ completionBlock:^(NSDictionary<NSString *,RCIntroEligibility *> * _Nonnull responseDictionary) {
208
+ resolve([NSDictionary dictionaryWithDictionary:responseDictionary]);
209
+ }];
210
+ }
211
+
212
+ RCT_REMAP_METHOD(getPaymentDiscount,
213
+ getPaymentDiscountForProductIdentifier:(NSString *)productIdentifier
214
+ discountIdentifier:(nullable NSString *)discountIdentifier
215
+ resolve:(RCTPromiseResolveBlock)resolve
216
+ reject:(RCTPromiseRejectBlock)reject) {
217
+ [RCCommonFunctionality paymentDiscountForProductIdentifier:productIdentifier
218
+ discount:discountIdentifier
219
+ completionBlock:[self getResponseCompletionBlockWithResolve:resolve
220
+ reject:reject]];
221
+ }
222
+
223
+ RCT_EXPORT_METHOD(invalidatePurchaserInfoCache) {
224
+ [RCCommonFunctionality invalidatePurchaserInfoCache];
225
+ }
226
+
227
+ RCT_EXPORT_METHOD(presentCodeRedemptionSheet) {
228
+ if (@available(iOS 14.0, *)) {
229
+ [RCCommonFunctionality presentCodeRedemptionSheet];
230
+ } else {
231
+ NSLog(@"[Purchases] Warning: tried to present codeRedemptionSheet, but it's only available on iOS 14.0 or greater.");
232
+ }
233
+ }
234
+
235
+ #pragma mark - Subscriber Attributes
236
+
237
+ RCT_EXPORT_METHOD(setProxyURLString:(nullable NSString *)proxyURLString) {
238
+ [RCCommonFunctionality setProxyURLString:proxyURLString];
239
+ }
240
+
241
+ RCT_EXPORT_METHOD(setAttributes:(NSDictionary *)attributes) {
242
+ [RCCommonFunctionality setAttributes:attributes];
243
+ }
244
+
245
+ RCT_EXPORT_METHOD(setEmail:(NSString *)email) {
246
+ [RCCommonFunctionality setEmail:email];
247
+ }
248
+
249
+ RCT_EXPORT_METHOD(setPhoneNumber:(NSString *)phoneNumber) {
250
+ [RCCommonFunctionality setPhoneNumber:phoneNumber];
251
+ }
252
+
253
+ RCT_EXPORT_METHOD(setDisplayName:(NSString *)displayName) {
254
+ [RCCommonFunctionality setDisplayName:displayName];
255
+ }
256
+
257
+ RCT_EXPORT_METHOD(setPushToken:(NSString *)pushToken) {
258
+ [RCCommonFunctionality setPushToken:pushToken];
259
+ }
260
+
261
+ # pragma mark Attribution IDs
262
+
263
+ RCT_EXPORT_METHOD(collectDeviceIdentifiers) {
264
+ [RCCommonFunctionality collectDeviceIdentifiers];
265
+ }
266
+
267
+ RCT_EXPORT_METHOD(setAdjustID:(NSString *)adjustID) {
268
+ [RCCommonFunctionality setAdjustID:adjustID];
269
+ }
270
+
271
+ RCT_EXPORT_METHOD(setAppsflyerID:(NSString *)appsflyerID) {
272
+ [RCCommonFunctionality setAppsflyerID:appsflyerID];
273
+ }
274
+
275
+ RCT_EXPORT_METHOD(setFBAnonymousID:(NSString *)fbAnonymousID) {
276
+ [RCCommonFunctionality setFBAnonymousID:fbAnonymousID];
277
+ }
278
+
279
+ RCT_EXPORT_METHOD(setMparticleID:(NSString *)mparticleID) {
280
+ [RCCommonFunctionality setMparticleID:mparticleID];
281
+ }
282
+
283
+ RCT_EXPORT_METHOD(setOnesignalID:(NSString *)onesignalID) {
284
+ [RCCommonFunctionality setOnesignalID:onesignalID];
285
+ }
286
+
287
+ RCT_EXPORT_METHOD(setAirshipChannelID:(NSString *)airshipChannelID) {
288
+ [RCCommonFunctionality setAirshipChannelID:airshipChannelID];
289
+ }
290
+
291
+ # pragma mark Campaign parameters
292
+
293
+ RCT_EXPORT_METHOD(setMediaSource:(NSString *)mediaSource) {
294
+ [RCCommonFunctionality setMediaSource:mediaSource];
295
+ }
296
+
297
+ RCT_EXPORT_METHOD(setCampaign:(NSString *)campaign) {
298
+ [RCCommonFunctionality setCampaign:campaign];
299
+ }
300
+
301
+ RCT_EXPORT_METHOD(setAdGroup:(NSString *)adGroup) {
302
+ [RCCommonFunctionality setAdGroup:adGroup];
303
+ }
304
+
305
+ RCT_EXPORT_METHOD(setAd:(NSString *)ad) {
306
+ [RCCommonFunctionality setAd:ad];
307
+ }
308
+
309
+ RCT_EXPORT_METHOD(setKeyword:(NSString *)keyword) {
310
+ [RCCommonFunctionality setKeyword:keyword];
311
+ }
312
+
313
+ RCT_EXPORT_METHOD(setCreative:(NSString *)creative) {
314
+ [RCCommonFunctionality setCreative:creative];
315
+ }
316
+
317
+ RCT_REMAP_METHOD(canMakePayments,
318
+ canMakePaymentsWithFeatures:(NSArray<NSNumber *> *)features
319
+ resolve:(RCTPromiseResolveBlock)resolve
320
+ reject:(RCTPromiseRejectBlock)reject) {
321
+ resolve(@([RCCommonFunctionality canMakePaymentsWithFeatures:features]));
322
+ }
323
+
324
+ RCT_REMAP_METHOD(isConfigured,
325
+ isConfiguredWithResolve:(RCTPromiseResolveBlock)resolve
326
+ reject:(RCTPromiseRejectBlock)reject) {
327
+ resolve(@(RCPurchases.isConfigured));
328
+ }
329
+
330
+ #pragma mark -
331
+ #pragma mark Delegate Methods
332
+ - (void)purchases:(RCPurchases *)purchases didReceiveUpdatedPurchaserInfo:(RCPurchaserInfo *)purchaserInfo {
333
+ [self sendEventWithName:RNPurchasesPurchaserInfoUpdatedEvent body:purchaserInfo.dictionary];
334
+ }
335
+
336
+ - (void) purchases:(RCPurchases *)purchases
337
+ shouldPurchasePromoProduct:(SKProduct *)product
338
+ defermentBlock:(RCDeferredPromotionalPurchaseBlock)makeDeferredPurchase {
339
+ if (!self.defermentBlocks) {
340
+ self.defermentBlocks = [NSMutableArray array];
341
+ }
342
+ [self.defermentBlocks addObject:makeDeferredPurchase];
343
+ NSInteger position = [self.defermentBlocks count] - 1;
344
+ [self sendEventWithName:RNPurchasesShouldPurchasePromoProductEvent body:@{@"callbackID": @(position)}];
345
+ }
346
+
347
+ #pragma mark -
348
+ #pragma mark Helper Methods
349
+
350
+ - (void)rejectPromiseWithBlock:(RCTPromiseRejectBlock)reject error:(NSError *)error {
351
+ reject([NSString stringWithFormat: @"%ld", (long)error.code], error.localizedDescription, error);
352
+ }
353
+
354
+ - (void (^)(NSDictionary *, RCErrorContainer *))getResponseCompletionBlockWithResolve:(RCTPromiseResolveBlock)resolve
355
+ reject:(RCTPromiseRejectBlock)reject {
356
+ return ^(NSDictionary *_Nullable responseDictionary, RCErrorContainer *_Nullable error) {
357
+ if (error) {
358
+ reject([NSString stringWithFormat:@"%ld", (long) error.code], error.message, error.error);
359
+ } else if (responseDictionary) {
360
+ resolve([NSDictionary dictionaryWithDictionary:responseDictionary]);
361
+ } else {
362
+ resolve(nil);
363
+ }
364
+ };
365
+ }
366
+
367
+ - (NSString *)platformFlavor {
368
+ return @"react-native";
369
+ }
370
+
371
+ - (NSString *)platformFlavorVersion {
372
+ return @"4.6.2";
373
+ }
374
+
375
+ @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": "4.6.1",
4
+ "version": "4.6.2",
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",
@@ -0,0 +1,19 @@
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
+ }