Analytics Region Gate on iOS When the SIM Country Is Unreadable
By Nesim Razon, independent mobile developer · 2026-11-17
Two of our apps collect usage statistics only on devices outside the European Economic Area, the United Kingdom and Switzerland, so that no consent form is needed. On Android that is easy to check. On iPhone the SIM and network country cannot be read, so the same rule needed a different set of signals. This is how the rule is written once in Kotlin Multiplatform, and what it does when it is unsure. It describes our own design choice, not legal advice.
The rule in one sentence
Analytics is on only when we are sure the device is outside the restricted regions. If any signal points to a restricted country, it is off. If no signal is known at all, it is off. Being unsure always means off.
The rule lives in common code, so Android and iPhone cannot drift apart. It is a function that takes any number of country codes, some of which can be missing, and returns whether collection is allowed.
The shared function
The function trims each value, upper-cases it and keeps only two-letter codes. If nothing is left, it returns false. Otherwise it returns true only when none of the codes is in the restricted set: the EU member states, Iceland, Liechtenstein and Norway, the United Kingdom and Switzerland.
Upper-casing matters, because platforms report codes differently, and an empty or malformed value must count as unknown rather than as allowed. The unit tests cover exactly these cases: Turkey passes, a single restricted code anywhere fails (a Turkish phone with a German SIM is treated as restricted), lower-case codes are normalised, and no data at all means off.
Android: three signals
On Android the app can read the device region, the SIM country and the network country. They are passed together into the function. A traveller in Germany with a Turkish SIM, or a German resident with a Turkish SIM, both end up with collection off, because any restricted value wins.
The collection flag is off by default in the manifest, and the app decides again on every launch. A debug or staging build never collects, because collection also needs the release build flag.
iPhone: fewer signals
On iPhone the SIM and network country are not available to an ordinary app. What remains is the device region from the locale, which reflects a setting the user chose, and the time zone, which reflects where the phone actually is.
So the iOS side passes the locale's country code to the same function and adds a second check on the time zone name. Any zone that starts with Europe/ counts as restricted, as do a few Atlantic and African zones that belong to restricted countries, such as Madeira, the Canary Islands, the Azores, the Faroe Islands and Ceuta.
The Istanbul exception
Europe/Istanbul starts with Europe/ but Turkey is not in the restricted set, and these are Turkish news apps. The time zone check has one explicit exception for it. Without that line, almost every Turkish iPhone would have been switched off.
The time zone check is deliberately blunt. It will sometimes switch analytics off for someone outside the restricted regions, for example a traveller in Paris with a Turkish locale, and that is the safe direction to be wrong in.
What the code does not do
The iOS project also ships with automatic collection switched off in its property list, and the app turns it on in code only when the rule allows. There is no advertising identifier, and the apps contain no ads. Events carry a category or a type, never personal data.
The pieces to copy are small: a restricted set, a function that treats unknown as off, a time zone helper with an explicit exception for your home zone, and unit tests that fix the behaviour. The decision about which regions to exclude is yours and your adviser's, not the code's.
Frequently asked questions
Why not just ask for consent everywhere?
Because these two apps are small and ad-free, and we preferred not to show a consent form at all. Turning collection off in the restricted regions was the simpler design for us.
Why can iOS not use the SIM country?
An ordinary iPhone app cannot read the SIM or network country, so the iOS side uses the locale region and the time zone instead.
What happens when the signals are missing or conflict?
Collection stays off. Unknown counts as off, and any single restricted value switches it off.
Is this legal advice?
No. It is a description of how we built our own rule. Decide for your own apps with proper advice.
More from the blog
- The iOS Build Number That Stayed at 1: Three Failed Fixes and One That Worked
- Why My App Store Link Returned 404 and the Page Showed 2018 Screenshots
- App Store Review Guideline 2.1 "Information Needed": What I Sent
- App Store Screenshots Without a Phone: Robolectric, a Fake Image Loader and a Headless Browser
- One QR Code for Two App Stores: A Tiny Redirect Page
- Rewriting for Kotlin Multiplatform Without Changing Behavior: Old Code as a Test Oracle