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

Use MAS region instead of macOS region #684

Closed
rgoldberg opened this issue Dec 29, 2024 · 0 comments · Fixed by #689
Closed

Use MAS region instead of macOS region #684

rgoldberg opened this issue Dec 29, 2024 · 0 comments · Fixed by #689

Comments

@rgoldberg
Copy link
Contributor

Overview

Use MAS region instead of macOS region on macOS 10.15+.

macOS 10.13 - 10.14 will continue to use the macOS region.

This is only for reading the MAS region to pass as a country query string parameter value to the iTunes Search Web API queries (in mas info, mas search, and other commands that call the API), as all other places use Apple private frameworks that internally use the MAS region without mas directly seeing it.

This is not about setting the region, either for the MAS (the source is read only; for setting the region, see #75) or for an individual run of any mas command (e.g., via a --region option; see #444).

I think we should also add an mas region command to output the region that mas uses, so users can easily see that. Note that this minimal version of the command will not take any arguments, and will not currently set any values, just display info. The same command can be used to implement #75 by allowing it to accept appropriate arguments.

Implementation

SKStorefront (available on macOS 10.15+, deprecated on macOS 12, but seemingly still around on macOS 15) provides the region used in the MAS via its countryCode read-only property. (annoyingly, it provides an ISO 3166 alpha-3 3-character region code instead of an alpha-2 2-character region code that is used by the iTunes Search Web API, so I had to depend on a library to map from alpha-3 to alpha-2).

If you are logged out of the MAS, it seems to return the most recent region set in the MAS.

SKPaymentQueue.default().storefront provides the current SKStorefront.

Storefront is the macOS 12+ alternative for SKStorefront, but it uses Swift Concurrency. If we later learn how to use Swift Concurrency without Swift Concurrency cascading out of an if #avaialble(macOS 12, *) {…} block, or if we increase the minimum required macOS to 10.15, we can start to use Storefront for macOS 12+, but not probably worth the effort now.

There are a few ways to structure this. Will want to discuss the exact implementation after I submit my PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant