Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make it build with older XCode #650

Merged
merged 1 commit into from
Aug 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ios/RNIapIos.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ - (BOOL)shouldAddStorePayment:(SKPayment *)payment forProduct:(SKProduct *)produ
}
if (product) {
payment = [SKMutablePayment paymentWithProduct:product];
#if __IPHONE_12_2
if (@available(iOS 12.2, *)) {
SKPaymentDiscount *discount = [[SKPaymentDiscount alloc]
initWithIdentifier:discountOffer[@"identifier"]
Expand All @@ -190,6 +191,7 @@ - (BOOL)shouldAddStorePayment:(SKPayment *)payment forProduct:(SKProduct *)produ
];
payment.paymentDiscount = discount;
}
#endif
payment.applicationUsername = usernameHash;
[[SKPaymentQueue defaultQueue] addPayment:payment];
[self addPromiseForKey:RCTKeyForInstance(payment.productIdentifier) resolve:resolve reject:reject];
Expand Down Expand Up @@ -567,9 +569,11 @@ -(NSDictionary*)getProductObject:(SKProduct *)product {
}

NSArray *discounts;
#if __IPHONE_12_2
if (@available(iOS 12.2, *)) {
discounts = [self getDiscountData:[product.discounts copy]];
}
#endif

NSDictionary *obj = [NSDictionary dictionaryWithObjectsAndKeys:
product.productIdentifier, @"productId",
Expand Down Expand Up @@ -645,6 +649,7 @@ - (NSMutableArray *)getDiscountData:(NSArray *)discounts {


NSString* discountIdentifier = @"";
#if __IPHONE_12_2
if (@available(iOS 12.2, *)) {
discountIdentifier = discount.identifier;
switch (discount.type) {
Expand All @@ -660,6 +665,7 @@ - (NSMutableArray *)getDiscountData:(NSArray *)discounts {
}

}
#endif

[mappedDiscounts addObject:[NSDictionary dictionaryWithObjectsAndKeys:
discountIdentifier, @"identifier",
Expand Down