Skip to content

Commit

Permalink
Add introductory price as string without formating and currency
Browse files Browse the repository at this point in the history
  • Loading branch information
accolite-maggarwall committed Nov 13, 2020
1 parent fa43b88 commit a0474f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ Property | iOS | And | Comment
`title` | ✓ | ✓ | Returns the title Android and localizedTitle on iOS.
`description` | ✓ | ✓ | Returns the localized description on Android and iOS.
`introductoryPrice` | ✓ | ✓ | Formatted introductory price of a subscription, including its currency sign, such as €3.99.<br>The price doesn't include tax.
`introductoryPriceAsAmountIOS` | ✓ | | Localized introductory price string, with only number (eg. `0.99`).
`introductoryPricePaymentModeIOS` | ✓ | | The payment mode for this product discount.
`introductoryPriceNumberOfPeriods` | ✓ | | An integer that indicates the number of periods the product discount is available.
`introductoryPriceNumberOfPeriodsIOS` | ✓ | | An integer that indicates the number of periods the product discount is available.
Expand Down
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface Subscription extends Common {
discounts?: Discount[];

introductoryPrice?: string;
introductoryPriceAsAmountIOS?: string;
introductoryPricePaymentModeIOS?: string;
introductoryPriceNumberOfPeriodsIOS?: string;
introductoryPriceSubscriptionPeriodIOS?: string;
Expand Down
4 changes: 4 additions & 0 deletions ios/RNIapIos.m
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ -(NSDictionary*)getProductObject:(SKProduct *)product {

NSString* localizedPrice = [formatter stringFromNumber:product.price];
NSString* introductoryPrice = localizedPrice;
NSString* introductoryPriceAsAmountIOS = [product.price stringValue];

NSString* introductoryPricePaymentMode = @"";
NSString* introductoryPriceNumberOfPeriods = @"";
Expand Down Expand Up @@ -558,6 +559,7 @@ -(NSDictionary*)getProductObject:(SKProduct *)product {
//SKProductDiscount introductoryPriceObj = product.introductoryPrice;
formatter.locale = product.introductoryPrice.priceLocale;
introductoryPrice = [formatter stringFromNumber:product.introductoryPrice.price];
introductoryPriceAsAmountIOS = [product.introductoryPrice.price stringValue];

switch (product.introductoryPrice.paymentMode) {
case SKProductDiscountPaymentModeFreeTrial:
Expand Down Expand Up @@ -592,6 +594,7 @@ -(NSDictionary*)getProductObject:(SKProduct *)product {

} else {
introductoryPrice = @"";
introductoryPriceAsAmountIOS = @"";
introductoryPricePaymentMode = @"";
introductoryPriceNumberOfPeriods = @"";
introductoryPriceSubscriptionPeriod = @"";
Expand Down Expand Up @@ -620,6 +623,7 @@ -(NSDictionary*)getProductObject:(SKProduct *)product {
periodNumberIOS, @"subscriptionPeriodNumberIOS",
periodUnitIOS, @"subscriptionPeriodUnitIOS",
introductoryPrice, @"introductoryPrice",
introductoryPriceAsAmountIOS, @"introductoryPriceAsAmountIOS",
introductoryPricePaymentMode, @"introductoryPricePaymentModeIOS",
introductoryPriceNumberOfPeriods, @"introductoryPriceNumberOfPeriodsIOS",
introductoryPriceSubscriptionPeriod, @"introductoryPriceSubscriptionPeriodIOS",
Expand Down

0 comments on commit a0474f2

Please sign in to comment.