To adhere to local laws (mostly EU/USA for now) I need to know which country store my app has been downloaded. How can I find this?
I only see implementations that use the local time zone, but that is not sufficient by Apple. Eg if someone is on holiday inside the EU, I should not be able to show that people are able to buy a subscription from the website.
Thank you!
You can’t directly get the country where your app was downloaded from via the Play Store or App Store through the Ionic/Capacitor runtime.
-
Use Device Locale or Region Info: You can use the @capacitor/device
plugin to retrieve the device’s locale and region. This gives you the user’s device settings, which usually correlate with their store location, but not always
-
IP-Based Location: If you want more accurate geolocation at install or login, implement a simple IP-based lookup via your backend (like using IPinfo, GeoIP, MaxMind)
-
Analytics Tools:
Services like:
- Firebase Analytics
- Google Play Console => Statistics => User acquisition
- App Store Connect => Metrics => Acquisition
For legal compliance, you probably want to get the country code from Apple’s API itself; with any other method, you are guessing, and Apple may object to that.
You can get the countryCode from StoreKit; there may be an existing Capacitor plugin that does this, or you may have to write the code on your own.