-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[in_app_purchase] add Storefront.countryCode() and AppStore.sync() #8900
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
Changes from 12 commits
a5b8be6
fb336f2
3975176
6e36806
bd28299
6879d20
bc47383
e1d8e4a
6d4f358
5b225f9
272fecf
7751325
cde9e8c
b1c712c
bae45d4
407752b
1cbbc14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| ## 0.3.22 | ||
|
|
||
| * Adds `sync()` and `countryCode()`. | ||
|
|
||
| ## 0.3.21 | ||
|
|
||
| * Adds Swift Package Manager compatibility. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ import StoreKit | |
|
|
||
| @available(iOS 15.0, macOS 12.0, *) | ||
| extension InAppPurchasePlugin: InAppPurchase2API { | ||
|
|
||
| // MARK: - Pigeon Functions | ||
|
|
||
| /// Wrapper method around StoreKit2's canMakePayments() method | ||
|
|
@@ -146,6 +145,31 @@ extension InAppPurchasePlugin: InAppPurchase2API { | |
| } | ||
| } | ||
|
|
||
| /// Wrapper method around StoreKit2's countryCode() method | ||
| /// https://developer.apple.com/documentation/storekit/storefront/countrycode | ||
| func countryCode(completion: @escaping (Result<String, Error>) -> Void) { | ||
| Task { | ||
| guard let currentStorefront = await Storefront.current else { | ||
| let error = PigeonError( | ||
| code: "storekit2_failed_to_fetch_country_code", | ||
| message: "Storekit has failed to fetch the country code.", | ||
| details: "Storekit has failed to fetch the country code.") | ||
| return completion(.failure(error)) | ||
|
||
| } | ||
| return completion(.success(currentStorefront.countryCode)) | ||
LouiseHsu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| func sync(completion: @escaping (Result<Void, Error>) -> Void) { | ||
| Task { | ||
| do { | ||
| try await AppStore.sync() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing completion on success. |
||
| } catch { | ||
| fatalError("Failed to sync to the AppStore: \(error)") | ||
LouiseHsu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| /// This Task listens to Transation.updates as shown here | ||
| /// https://developer.apple.com/documentation/storekit/transaction/3851206-updates | ||
| /// This function should be called as soon as the app starts to avoid missing any Transactions done outside of the app. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.