Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 17 commits into from
Apr 17, 2025

Conversation

LouiseHsu
Copy link
Contributor

@LouiseHsu LouiseHsu commented Mar 26, 2025

Fixes flutter/flutter#159631 and fixes flutter/flutter#165659

Adds iap support for accessing store front country code and manual transaction syncing.

Pre-Review Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I [linked to at least one issue that this PR fixes] in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy], or I have commented below to indicate which [version change exemption] this PR falls under[^1].
  • I updated CHANGELOG.md to add a description of the change, [following repository CHANGELOG style], or I have commented below to indicate which [CHANGELOG exemption] this PR falls under[^1].
  • I updated/added any relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or I have commented below to indicate which [test exemption] this PR falls under[^1].
  • All existing and new tests are passing.

@LouiseHsu LouiseHsu changed the title bonk adds appstore.sync, appstore.countrycode Mar 26, 2025
@LouiseHsu LouiseHsu changed the title adds appstore.sync, appstore.countrycode [in_app_purchase] add Storefront.countryCode() and AppStore.sync() Apr 1, 2025
@LouiseHsu LouiseHsu requested a review from hellohuanlin April 1, 2025 23:14
@LouiseHsu LouiseHsu marked this pull request as ready for review April 1, 2025 23:14
code: "storekit2_failed_to_fetch_country_code",
message: "Storekit has failed to fetch the country code.",
details: "Storefront.current returned nil.")
return completion(.failure(error))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

completion(.failure(error))
return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i changed it but whats the difference in practice?

Copy link
Contributor

@hellohuanlin hellohuanlin Apr 16, 2025

Choose a reason for hiding this comment

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

Let's say we have a function that doesn't return:

func print(stuff: String) {
  ...
}

When we call it, we simply do:

if wannaPrint {
  print(stuff: "abc")
}

And if we want to early return, just do:

if wannaPrint {
  print(stuff: "abc")
  return
}

Now, what you were trying to do was:

if wannaPrint {
  return print(stuff: "abc")
}

For most languages, this code won't even compile. However, it compiles fine here in Swift, because Void is an actual type in Swift. So the above code is equivalent to:

if wannaPrint {
  let answer = print(stuff: "abc")
  return answer
}

Here the answer is of type Void, and of value Void(). While it's perfectly valid to write return Void(), I have never seen anyone writing it. People just do return for a function that returns void.

A fun fact, do you know thatVoid is a typealias of an empty tuple?

public typealias Void = ()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, that makes sense.

func sync(completion: @escaping (Result<Void, Error>) -> Void) {
Task {
do {
try await AppStore.sync()
Copy link
Contributor

Choose a reason for hiding this comment

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

missing completion on success.

@LouiseHsu LouiseHsu requested a review from hellohuanlin April 17, 2025 18:09
/// (https://developer.apple.com/documentation/storekit/storefront/countrycode)
Future<String> countryCode() async {
final String code = await _hostApi.countryCode();
return code;
Copy link
Contributor

Choose a reason for hiding this comment

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

can it just be return _hostApi.countryCode()?

Task {
do {
try await AppStore.sync()
completion(.success(Void()))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Void() => ()

@LouiseHsu LouiseHsu added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 17, 2025
@auto-submit auto-submit bot merged commit 2e4309c into flutter:main Apr 17, 2025
82 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 21, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Apr 21, 2025
flutter/packages@2fcc403...ac21f53

2025-04-20 [email protected] Roll Flutter from
3ed38e2 to cfb887c (17 revisions) (flutter/packages#9118)
2025-04-19 [email protected] [various] Scrubs pre-SDK-21 Android
code (flutter/packages#9112)
2025-04-18 [email protected] Roll Flutter from
ecabb1a to 3ed38e2 (23 revisions) (flutter/packages#9114)
2025-04-18 [email protected] [flutter_svg] feat: Expose the
`colorMapper` property in `SvgPicture` (flutter/packages#9043)
2025-04-18 [email protected] [tool] Add initial file-based command
skipping (flutter/packages#8928)
2025-04-18 [email protected] [pigeon] Convert test plugins to SPM
(flutter/packages#9105)
2025-04-18 [email protected]
[webview_flutter] Adds support to control overscrolling
(flutter/packages#8451)
2025-04-17 [email protected] [in_app_purchase] add
Storefront.countryCode() and AppStore.sync() (flutter/packages#8900)
2025-04-17 [email protected]
[webview_flutter_wkwebview] Expose the allowsLinkPreview property in
WKWebView for iOS (flutter/packages#5029)
2025-04-17 [email protected]
[webview_flutter_android][webview_flutter_wkwebview] Adds platform
implementations to set over-scroll mode (flutter/packages#9101)
2025-04-17 [email protected]
[shared_preferences] Update AGP to 8.9.1 (flutter/packages#9106)
2025-04-17 [email protected] [pigeon] Adds
Kotlin lint tests to example code and fix lints (flutter/packages#9034)
2025-04-17 [email protected]
[video_player_avfoundation] enable more than 30 fps
(flutter/packages#7466)
2025-04-17 [email protected] Roll Flutter from
aef4718 to ecabb1a (25 revisions) (flutter/packages#9104)
2025-04-16 [email protected] [pigeon] Unify iOS and macOS test
plugins (flutter/packages#9100)
2025-04-16 [email protected] Roll Flutter from
db68c95 to aef4718 (7 revisions) (flutter/packages#9098)
2025-04-16 [email protected]
[webview_flutter_platform_interface] Adds method to set overscroll mode
(flutter/packages#9099)
2025-04-16 [email protected] Update `CODEOWNERS`
(flutter/packages#8984)
2025-04-16 [email protected] [google_sign_is] Update iOS SDK to
8.0 (flutter/packages#9081)
2025-04-16 [email protected] [camera_avfoundation]
Implementation swift migration (flutter/packages#8988)
2025-04-16 [email protected] [go_router]
Adds `caseSensitive` to `GoRoute` (flutter/packages#8992)
2025-04-16 [email protected] Manual roll Flutter from
30e53b0 to db68c95 (98 revisions) (flutter/packages#9092)
2025-04-15 [email protected] [tool] Run config-only build for
iOS/macOS native-test (flutter/packages#9080)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
CodixNinja pushed a commit to CodixNinja/flutter that referenced this pull request May 15, 2025
flutter/packages@2fcc403...ac21f53

2025-04-20 [email protected] Roll Flutter from
409a8ac to cd51fa3 (17 revisions) (flutter/packages#9118)
2025-04-19 [email protected] [various] Scrubs pre-SDK-21 Android
code (flutter/packages#9112)
2025-04-18 [email protected] Roll Flutter from
d0741df to 409a8ac (23 revisions) (flutter/packages#9114)
2025-04-18 [email protected] [flutter_svg] feat: Expose the
`colorMapper` property in `SvgPicture` (flutter/packages#9043)
2025-04-18 [email protected] [tool] Add initial file-based command
skipping (flutter/packages#8928)
2025-04-18 [email protected] [pigeon] Convert test plugins to SPM
(flutter/packages#9105)
2025-04-18 [email protected]
[webview_flutter] Adds support to control overscrolling
(flutter/packages#8451)
2025-04-17 [email protected] [in_app_purchase] add
Storefront.countryCode() and AppStore.sync() (flutter/packages#8900)
2025-04-17 [email protected]
[webview_flutter_wkwebview] Expose the allowsLinkPreview property in
WKWebView for iOS (flutter/packages#5029)
2025-04-17 [email protected]
[webview_flutter_android][webview_flutter_wkwebview] Adds platform
implementations to set over-scroll mode (flutter/packages#9101)
2025-04-17 [email protected]
[shared_preferences] Update AGP to 8.9.1 (flutter/packages#9106)
2025-04-17 [email protected] [pigeon] Adds
Kotlin lint tests to example code and fix lints (flutter/packages#9034)
2025-04-17 [email protected]
[video_player_avfoundation] enable more than 30 fps
(flutter/packages#7466)
2025-04-17 [email protected] Roll Flutter from
9616f9c to d0741df (25 revisions) (flutter/packages#9104)
2025-04-16 [email protected] [pigeon] Unify iOS and macOS test
plugins (flutter/packages#9100)
2025-04-16 [email protected] Roll Flutter from
a7ce7ff to 9616f9c (7 revisions) (flutter/packages#9098)
2025-04-16 [email protected]
[webview_flutter_platform_interface] Adds method to set overscroll mode
(flutter/packages#9099)
2025-04-16 [email protected] Update `CODEOWNERS`
(flutter/packages#8984)
2025-04-16 [email protected] [google_sign_is] Update iOS SDK to
8.0 (flutter/packages#9081)
2025-04-16 [email protected] [camera_avfoundation]
Implementation swift migration (flutter/packages#8988)
2025-04-16 [email protected] [go_router]
Adds `caseSensitive` to `GoRoute` (flutter/packages#8992)
2025-04-16 [email protected] Manual roll Flutter from
f2d54fd to a7ce7ff (98 revisions) (flutter/packages#9092)
2025-04-15 [email protected] [tool] Run config-only build for
iOS/macOS native-test (flutter/packages#9080)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: in_app_purchase platform-ios platform-macos
Projects
None yet
2 participants