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

Update eventEmitter.ts #2839

Merged
merged 3 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-example-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: brew install swiftlint

- name: SwiftLint
run: swiftlint lint --fix --format --path ios/*.swift --config .swiftlint.yml
run: yarn lint:swift

- name: Verify no files have changed after auto-fix
run: git diff --exit-code HEAD '*.swift'
Expand Down
7 changes: 7 additions & 0 deletions ios/IapSerializationUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func serialize(_ sp: Product.SubscriptionPeriod.Unit?) -> String? {
case .week: return "week"
case .month: return "month"
case .year: return "year"

default:
return nil
}
Expand Down Expand Up @@ -112,6 +113,7 @@ func serialize(_ rs: Product.SubscriptionInfo.RenewalState?) -> String? {
case .inGracePeriod: return "inGracePeriod"
case .revoked: return "revoked"
case .subscribed: return "subscribed"

default:
return nil
}
Expand Down Expand Up @@ -144,6 +146,7 @@ func serialize(_ pm: Product.SubscriptionOffer.PaymentMode?) -> String? {
case .freeTrial: return "freeTrial"
case .payAsYouGo: return "payAsYouGo"
case .payUpFront: return "payUpFront"

default:
return nil
}
Expand All @@ -154,6 +157,7 @@ func serialize(_ ot: Product.SubscriptionOffer.OfferType?) -> String? {
switch ot {
case .introductory: return "introductory"
case .promotional: return "promotional"

default:
return nil
}
Expand Down Expand Up @@ -212,6 +216,7 @@ func serialize(_ ot: Transaction.OfferType?) -> String? {
case .promotional: return "promotional"
case .introductory: return "introductory"
case .code: return "code"

default:
return nil
}
Expand All @@ -222,6 +227,7 @@ func serialize(_ ot: Transaction.OwnershipType?) -> String? {
switch ot {
case .purchased: return "purchased"
case .familyShared: return "familyShared"

default:
return nil
}
Expand All @@ -234,6 +240,7 @@ func serialize(_ pt: Product.ProductType?) -> String? {
case .consumable: return "consumable"
case .nonConsumable: return "nonConsumable"
case .nonRenewable: return "nonRenewable"

default:
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions ios/RNIapIos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,10 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
switch discount.type {
case SKProductDiscount.Type.introductory:
discountType = "INTRODUCTORY"

case SKProductDiscount.Type.subscription:
discountType = "SUBSCRIPTION"

default:
discountType = ""
}
Expand Down
1 change: 1 addition & 0 deletions ios/RNIapIosSk2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ class RNIapIosSk2iOS15: Sk2Delegate {
switch rs {
case .success: return "success"
case .userCancelled: return "userCancelled"

default:
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"lint:eslint": "eslint --fix '**/*.{ts,tsx}'",
"lint:ci": "yarn lint:tsc && yarn lint:eslint -f ./node_modules/@firmnav/eslint-github-actions-formatter/dist/formatter.js && yarn lint:prettier",
"lint:prettier": "prettier --write \"**/*.{md,js,jsx,ts,tsx}\"",
"lint:swift": "swiftlint lint --fix --format --path ios/*.swift --config .swiftlint.yml",
"lint:swift": "swiftlint lint --fix --format ios/*.swift --config .swiftlint.yml",
"lint:kotlin": "ktlint --format",
"format": "git ls-files -m | xargs yarn prettier --write --ignore-unknown --no-error-on-unmatched-pattern",
"bootstrap": "yarn example && yarn && yarn example pods",
Expand Down
9 changes: 8 additions & 1 deletion src/eventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const App = () => {
*/
export const purchaseUpdatedListener = (
listener: (event: Purchase) => void,
errorCallback?: (error: unknown) => void,
) => {
const eventEmitter = new NativeEventEmitter(getNativeModule());
const proxyListener = isIosStorekit2()
Expand All @@ -59,7 +60,13 @@ export const purchaseUpdatedListener = (
);

if (isAndroid) {
getAndroidModule().startListening();
getAndroidModule().startListening().catch((error: unknown) => {
if (errorCallback) {
errorCallback(error);
} else {
throw error;
}
});
}

return emitterSubscription;
Expand Down
Loading