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.
@@ -8,15 +8,17 @@
8
8
 
9
9
  @import StoreKit;
10
10
 
11
+ typedef void (^PurchaseCompletedBlock)(RCStoreTransaction *, RCCustomerInfo *, NSError *, BOOL);
12
+ typedef void (^StartPurchaseBlock)(PurchaseCompletedBlock);
11
13
 
12
14
  @interface RNPurchases () <RCPurchasesDelegate>
13
15
 
14
- @property (nonatomic, retain) NSMutableArray<RCDeferredPromotionalPurchaseBlock> *defermentBlocks;
16
+ @property (nonatomic, retain) NSMutableArray<StartPurchaseBlock> *defermentBlocks;
15
17
 
16
18
  @end
17
19
 
18
20
 
19
- NSString *RNPurchasesPurchaserInfoUpdatedEvent = @"Purchases-PurchaserInfoUpdated";
21
+ NSString *RNPurchasesCustomerInfoUpdatedEvent = @"Purchases-CustomerInfoUpdated";
20
22
  NSString *RNPurchasesShouldPurchasePromoProductEvent = @"Purchases-ShouldPurchasePromoProduct";
21
23
 
22
24
 
@@ -27,7 +29,7 @@ NSString *RNPurchasesShouldPurchasePromoProductEvent = @"Purchases-ShouldPurchas
27
29
  }
28
30
 
29
31
  - (NSArray<NSString *> *)supportedEvents {
30
- return @[RNPurchasesPurchaserInfoUpdatedEvent, RNPurchasesShouldPurchasePromoProductEvent];
32
+ return @[RNPurchasesCustomerInfoUpdatedEvent, RNPurchasesShouldPurchasePromoProductEvent];
31
33
  }
32
34
 
33
35
  RCT_EXPORT_MODULE();
@@ -35,16 +37,17 @@ RCT_EXPORT_MODULE();
35
37
  RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
36
38
  appUserID:(nullable NSString *)appUserID
37
39
  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];
40
+ userDefaultsSuiteName:(nullable NSString *)userDefaultsSuiteName
41
+ usesStoreKit2IfAvailable:(BOOL)usesStoreKit2IfAvailable) {
42
+ RCPurchases *purchases = [RCPurchases configureWithAPIKey:apiKey
43
+ appUserID:appUserID
44
+ observerMode:observerMode
45
+ userDefaultsSuiteName:userDefaultsSuiteName
46
+ platformFlavor:self.platformFlavor
47
+ platformFlavorVersion:self.platformFlavorVersion
48
+ usesStoreKit2IfAvailable:usesStoreKit2IfAvailable
49
+ dangerousSettings:nil];
50
+ purchases.delegate = self;
48
51
  }
49
52
 
50
53
  RCT_EXPORT_METHOD(setAllowSharingStoreAccount:(BOOL)allowSharingStoreAccount) {
@@ -58,15 +61,6 @@ RCT_EXPORT_METHOD(setFinishTransactions:(BOOL)finishTransactions) {
58
61
  [RCCommonFunctionality setFinishTransactions:finishTransactions];
59
62
  }
60
63
 
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
64
  RCT_REMAP_METHOD(getOfferings,
71
65
  getOfferingsWithResolve:(RCTPromiseResolveBlock)resolve
72
66
  reject:(RCTPromiseRejectBlock)reject) {
@@ -112,8 +106,8 @@ RCT_REMAP_METHOD(purchasePackage,
112
106
  RCT_REMAP_METHOD(restoreTransactions,
113
107
  restoreTransactionsWithResolve:(RCTPromiseResolveBlock)resolve
114
108
  reject:(RCTPromiseRejectBlock)reject) {
115
- [RCCommonFunctionality restoreTransactionsWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve
116
- reject:reject]];
109
+ [RCCommonFunctionality restorePurchasesWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve
110
+ reject:reject]];
117
111
  }
118
112
 
119
113
  RCT_EXPORT_METHOD(syncPurchases) {
@@ -126,13 +120,6 @@ RCT_REMAP_METHOD(getAppUserID,
126
120
  resolve([RCCommonFunctionality appUserID]);
127
121
  }
128
122
 
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
123
  RCT_EXPORT_METHOD(logIn:(nonnull NSString *)appUserID
137
124
  resolve:(RCTPromiseResolveBlock)resolve
138
125
  reject:(RCTPromiseRejectBlock)reject) {
@@ -146,25 +133,6 @@ RCT_REMAP_METHOD(logOut,
146
133
  [RCCommonFunctionality logOutWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
147
134
  }
148
135
 
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
136
  RCT_REMAP_METHOD(setDebugLogsEnabled,
169
137
  debugLogsEnabled:(BOOL)enabled) {
170
138
  [RCCommonFunctionality setDebugLogsEnabled:enabled];
@@ -175,10 +143,10 @@ RCT_EXPORT_METHOD(setSimulatesAskToBuyInSandbox:(BOOL)simulatesAskToBuyInSandbox
175
143
  [RCCommonFunctionality setSimulatesAskToBuyInSandbox:simulatesAskToBuyInSandbox];
176
144
  }
177
145
 
178
- RCT_REMAP_METHOD(getPurchaserInfo,
179
- purchaserInfoWithResolve:(RCTPromiseResolveBlock)resolve
146
+ RCT_REMAP_METHOD(getCustomerInfo,
147
+ customerInfoWithResolve:(RCTPromiseResolveBlock)resolve
180
148
  reject:(RCTPromiseRejectBlock)reject) {
181
- [RCCommonFunctionality getPurchaserInfoWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
149
+ [RCCommonFunctionality getCustomerInfoWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
182
150
  }
183
151
 
184
152
  RCT_EXPORT_METHOD(setAutomaticAppleSearchAdsAttributionCollection:(BOOL)automaticAppleSearchAdsAttributionCollection)
@@ -195,7 +163,7 @@ RCT_REMAP_METHOD(isAnonymous,
195
163
  RCT_EXPORT_METHOD(makeDeferredPurchase:(nonnull NSNumber *)callbackID
196
164
  resolve:(RCTPromiseResolveBlock)resolve
197
165
  reject:(RCTPromiseRejectBlock)reject) {
198
- RCDeferredPromotionalPurchaseBlock defermentBlock = [self.defermentBlocks objectAtIndex:[callbackID integerValue]];
166
+ StartPurchaseBlock defermentBlock = [self.defermentBlocks objectAtIndex:[callbackID integerValue]];
199
167
  [RCCommonFunctionality makeDeferredPurchase:defermentBlock
200
168
  completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
201
169
  }
@@ -209,19 +177,18 @@ RCT_EXPORT_METHOD(checkTrialOrIntroductoryPriceEligibility:(NSArray *)products
209
177
  }];
210
178
  }
211
179
 
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]];
180
+ RCT_EXPORT_METHOD(invalidateCustomerInfoCache) {
181
+ [RCCommonFunctionality invalidateCustomerInfoCache];
221
182
  }
222
183
 
223
- RCT_EXPORT_METHOD(invalidatePurchaserInfoCache) {
224
- [RCCommonFunctionality invalidatePurchaserInfoCache];
184
+ RCT_REMAP_METHOD(getPromotionalOffer,
185
+ getPromotionalOfferForProductIdentifier:(NSString *)productIdentifier
186
+ discount:(NSString *)discount
187
+ resolve:(RCTPromiseResolveBlock)resolve
188
+ reject:(RCTPromiseRejectBlock)reject) {
189
+ [RCCommonFunctionality promotionalOfferForProductIdentifier:productIdentifier
190
+ discount:discount
191
+ completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
225
192
  }
226
193
 
227
194
  RCT_EXPORT_METHOD(presentCodeRedemptionSheet) {
@@ -329,17 +296,17 @@ RCT_REMAP_METHOD(isConfigured,
329
296
 
330
297
  #pragma mark -
331
298
  #pragma mark Delegate Methods
332
- - (void)purchases:(RCPurchases *)purchases didReceiveUpdatedPurchaserInfo:(RCPurchaserInfo *)purchaserInfo {
333
- [self sendEventWithName:RNPurchasesPurchaserInfoUpdatedEvent body:purchaserInfo.dictionary];
299
+ - (void)purchases:(RCPurchases *)purchases didReceiveUpdatedCustomerInfo:(RCCustomerInfo *)customerInfo {
300
+ [self sendEventWithName:RNPurchasesCustomerInfoUpdatedEvent body:customerInfo.dictionary];
334
301
  }
335
302
 
336
- - (void) purchases:(RCPurchases *)purchases
337
- shouldPurchasePromoProduct:(SKProduct *)product
338
- defermentBlock:(RCDeferredPromotionalPurchaseBlock)makeDeferredPurchase {
303
+ - (void)purchases:(RCPurchases *)purchases
304
+ readyForPromotedProduct:(RCStoreProduct *)product
305
+ purchase:(void (^)(void (^ _Nonnull)(RCStoreTransaction * _Nullable, RCCustomerInfo * _Nullable, NSError * _Nullable, BOOL)))startPurchase {
339
306
  if (!self.defermentBlocks) {
340
307
  self.defermentBlocks = [NSMutableArray array];
341
308
  }
342
- [self.defermentBlocks addObject:makeDeferredPurchase];
309
+ [self.defermentBlocks addObject:startPurchase];
343
310
  NSInteger position = [self.defermentBlocks count] - 1;
344
311
  [self sendEventWithName:RNPurchasesShouldPurchasePromoProductEvent body:@{@"callbackID": @(position)}];
345
312
  }
@@ -369,7 +336,7 @@ shouldPurchasePromoProduct:(SKProduct *)product
369
336
  }
370
337
 
371
338
  - (NSString *)platformFlavorVersion {
372
- return @"4.5.3";
339
+ return @"5.0.0-beta.1";
373
340
  }
374
341
 
375
342
  @end
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "react-native-purchases",
3
3
  "title": "React Native Purchases",
4
- "version": "4.6.0",
4
+ "version": "5.0.0-beta.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",
8
8
  "source": "src/index",
9
9
  "files": [
10
- "scripts/build.js",
11
10
  "dist",
12
11
  "android",
13
12
  "!android/gradlew*",
@@ -30,12 +29,11 @@
30
29
  "scripts": {
31
30
  "build": "tsc",
32
31
  "build-watch": "tsc --watch",
33
- "preinstall": "node scripts/build.js",
34
32
  "test": "jest",
35
33
  "tslint": "tslint -c tslint.json 'src/*.ts'",
36
34
  "prepublish": "tsc",
37
- "example": "(yarn --cwd examples/purchaseTester) && (yarn --cwd examples/purchaseTesterTypescript)",
38
- "pods": "(cd examples/purchaseTester && npx pod-install --quiet) && (cd examples/purchaseTesterTypescript && npx pod-install --quiet)",
35
+ "example": "yarn --cwd examples/MagicWeather && yarn --cwd examples/purchaseTesterTypescript",
36
+ "pods": "(cd examples/MagicWeather && npx pod-install --quiet) && (cd examples/purchaseTesterTypescript && npx pod-install --quiet)",
39
37
  "bootstrap": "yarn example && yarn && yarn pods"
40
38
  },
41
39
  "repository": {
@@ -72,12 +70,13 @@
72
70
  "ts-jest": "^24.1.0",
73
71
  "tslint": "^5.20.0",
74
72
  "tslint-config-prettier": "^1.18.0",
73
+ "typedoc": "^0.20.37",
75
74
  "typescript": "^3.8.3"
76
75
  },
77
76
  "jest": {
78
77
  "preset": "react-native",
79
78
  "modulePathIgnorePatterns": [
80
- "<rootDir>/examples/purchaseTester/node_modules",
79
+ "<rootDir>/examples/purchaseTesterTypescript/node_modules",
81
80
  "<rootDir>/lib/"
82
81
  ],
83
82
  "moduleFileExtensions": [
File without changes
@@ -0,0 +1,9 @@
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.2/" />
6
+ </head>
7
+ <body>
8
+ </body>
9
+ </html>
@@ -0,0 +1,9 @@
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.1/" />
6
+ </head>
7
+ <body>
8
+ </body>
9
+ </html>