Is there a way to know the cell carrier on an iPhone programmatically?
I am looking for the carrier name which the iPhone is connected to.
Is there a way to know the cell carrier on an iPhone programmatically?
I am looking for the carrier name which the iPhone is connected to.
Get carrier name from status bar in case if Core Telephony returns "Carrier"
While developing Alpha, I encountered the same problem. The project itself was not limited to use only public API, so first I tried @Jason Harwig's solution. Because I could not get it to work, I thought of another option.
My solution uses private API to access the
_serviceString
ivar of the label (UIStatusBarServiceItemView
) that is displayed in status bar.It relies on status bar having a carrier value and only needs
UIKit
to work.I only tested the method with applications that have status bar visible. It returns the same string as it is displayed in status bar, so it works correctly even when roaming.
This method is not App Store safe.
There is no public API for getting the carrier name. If you don't need to publish on the App Store you could look at using private api's.
VVCarrierParameters.h
in the VisualVoiceMail package seems to have acarrierServiceName
class method that might be what you need. Drop that header in your project and call[VVCarrierParameters carrierServiceName]
.Note your app will most likely be rejected if you do this.
For swift users you can try this:
https://developer.apple.com/iphone/prerelease/library/documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html#//apple_ref/doc/uid/TP40009596-CH1-DontLinkElementID_3
There is a such way however it's only available on iOS 4 so you won't be able to use it on previous versions. And this probably breaks your backward compatibility too.
In iOS 4, the CoreTelephony framework is useable, here's a snippet to get the carrier name:
Link against CoreTelephony and include in your headers: