Find out when device is (re-)connected to a foreign mobile network

Hello!


I have build an app which informs the user about roaming offers when the user is leaving the provider's home land (Germany). The app is running location services in background mode and makes a reverse geo-coding to find out the current country from time to time. So if the result is CH for Switzerland for example the user probably is in Switzerland and an offer for matching roaming products can be displayed. But I am looking for a solution which is faster, realtime if possible, and more safe. With my method the user can be in Switzerland but still logged in in the german home cell network. Or he is still in Germany but the iPhone has re-connected into a swiss network.

I know that in the past it was not possible to retrieve the current cell tower id or the cell provider name (only the home provider name) or the roaming state. Has something changed with the iOS versions starting with 13? There are some improvements and addons made to the network api so I hope that there are new ways, may be indirect, may be undocumented, to improve my implemented method which is really not more than a bad workaround.


Best regards

Marc

Replies

Has something changed with the iOS versions starting with 13?

No.

I’d like to clarify your requirements:

  • Do you want to know what country the user is physically located in?

  • Or what network they’re using?

I’ve worked with developers in both situations — usually due to the fine details of how a content licence was written — and the difference is important (as your DE / CH example shows).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Sorry Eskimo, I missed your reply. Also I had married on 21 Dec so I was a bit unfocused on my job. 🙂

To your question: Finally I just want to know if a device is in roaming state. As this is not directly measurable I thought that informations about the current used cell provider or the cell tower id could help. If there would be a way to track the cell provider name or cell tower id, the app could send this data to my server and the server returns "yes" if the cell tower id is located outside of Germany or "no" if it is not. (all apps are used only on devices with a german mobile network provider)


Best regards

Marc

Also I had married on 21 Dec

Congratulations!

Finally I just want to know if a device is in roaming state.

iOS has no mechanism to return that.

In my experience, requirements like this are best enforced on the server. That it, determine the IP addresses used by the acceptable WWAN providers and have your server reject requests from others. This has a bunch of benefits:

  • It works.

  • It’s secure in the presence of untrustworthy clients.

  • While maintaining this list is a bit of a pain, rolling it out is easy because it’s on your server.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"