Skip to content

Commit

Permalink
Resolve 228 again.
Browse files Browse the repository at this point in the history
Changes not made.
  • Loading branch information
hyochan committed Dec 15, 2018
1 parent a999f7c commit 48c3cbc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Changelogs
- **[2.3.22]**
- **[2.3.23]**
+ Resolve [#288](https://github.com/dooboolab/react-native-iap/issues/288).
- **[2.3.21]**
+ Fixed npe when `getAvailablePurcase` in android.
Expand Down
33 changes: 18 additions & 15 deletions ios/RNIapIos.m
Original file line number Diff line number Diff line change
Expand Up @@ -392,21 +392,24 @@ -(NSDictionary*)getProductObject:(SKProduct *)product {
currencyCode = product.priceLocale.currencyCode;
}

return @{
@"productId" : product.productIdentifier,
@"price" : [product.price stringValue],
@"currency" : currencyCode,
@"type": itemType,
@"title" : product.localizedTitle ? product.localizedTitle : @"",
@"description" : product.localizedDescription ? product.localizedDescription : @"",
@"localizedPrice" : localizedPrice,
@"subscriptionPeriodNumberIOS" : periodNumberIOS,
@"subscriptionPeriodUnitIOS" : periodUnitIOS,
@"introductoryPrice" : introductoryPrice,
@"introductoryPricePaymentModeIOS" : introductoryPricePaymentMode,
@"introductoryPriceNumberOfPeriodsIOS" : introductoryPriceNumberOfPeriods,
@"introductoryPriceSubscriptionPeriodIOS" : introductoryPriceSubscriptionPeriod
};
NSDictionary *obj = [NSDictionary dictionaryWithObjectsAndKeys:
product.productIdentifier, @"productId",
[product.price stringValue], @"price",
currencyCode, @"currency",
itemType, @"type",
product.localizedTitle ? product.localizedTitle : @"", @"title",
product.localizedDescription ? product.localizedDescription : @"", @"description",
localizedPrice, @"localizedPrice",
periodNumberIOS, @"subscriptionPeriodNumberIOS",
periodUnitIOS, @"subscriptionPeriodUnitIOS",
introductoryPrice, @"introductoryPrice",
introductoryPricePaymentMode, @"introductoryPricePaymentModeIOS",
introductoryPriceNumberOfPeriods, @"introductoryPriceNumberOfPeriodsIOS",
introductoryPriceSubscriptionPeriod, @"introductoryPriceSubscriptionPeriodIOS",
nil
];

return obj;
}

- (NSDictionary *)getPurchaseData:(SKPaymentTransaction *)transaction {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-iap",
"version": "2.3.22",
"version": "2.3.23",
"description": "React Native In App Purchase Module.",
"main": "index.js",
"types": "index.d.ts",
Expand Down

4 comments on commit 48c3cbc

@hyochan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. Commit message is wrong. This is meant to resolve #288

@mars-lan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but could you explain why replacing inline NSDictionary instantiation with dictionaryWithObjectsAndKeys fixed #288?

@hyochan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mars-lan No problem. As I’ve solved the same problem earlier here. This issue has been introduced in many stackoverflows that using NSDictionary in old way lead to misleading behavior in older devices. I just followed that. I know this is very ridiculous.

@mars-lan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. I totally didn't expect that. I thought the literal NSDictionary is just syntactic sugar for +[NSDictionary dictionaryWithObjects:forKeys:count:] (https://clang.llvm.org/docs/ObjectiveCLiterals.html#id2). Anyways, let's see if others can still reproduce #288 after the fix.

Please sign in to comment.