TiNetworkHelpers : Titanium module for CarrierInfo, CurrentNetwork & more.

I am happy to announce the first release of the TiNetworkHelpers project.  This module provides support for Carrier information, SSID, BSSID, and Apple’s Reachability utility class.

Download the release – You can download the compiled release here. Before doing so, please read the “Getting Started” section below to make sure you have all dependencies.

Work with the code – to learn more about the project, and download the source please head over to the repo on github here.

Currently TiNetworkHelpers is only available on iOS, with Android support coming shortly.

Below is a full description of the project and the features available in the first release.

Getting Started

Before installing TiNetworkHelpers there are a few things you need to keep in mind.

  • You need Titanium 1.8.1 or greater.  I recommend downloading the CI build available here.  When downloading please make sure you select the 1.8.X branch.  For instructions on how to install a CI Build please read this article.
  • This module has been tested only on iOS 5.  There isn’t any iOS 5 specific features referenced, so it should work on iOS 4.3+.
  • You can download a compiled release of TiNetworkHelpers  here.  If you need instructions on how to install a 3rd party module please read this.
  • If you are building from source, you will want to modify the titanium.xcconfig file to match your installation directories.

Import the module

After installing the module you need to reference the TiNetworkHelpers module by using the following require command.

Referencing the module  Available on gist here

CarrierInfo

CarrierInfo provides access to the native CTTelephonyNetworkInfo framework object.

carrierName – Provides access to the carrier name associated with the device’s SIM.

mobileCountryCode – Provides access to the carrier Mobile Country Codes (MCCs). This is the country code associated with the carrier on the SIM. Here is a listing off all the Mobile Country Codes on wikipedia.

mobileNetworkCode – Provides access to the carrier’s Mobile Network Code. This is the network code associated with the carrier on the SIM. Here is a listing off all the Mobile Network Codes for the US on wikipedia.

isoCountryCode – The ISO country code for the user’s cellular service provider. This is the carrier on the SIM.  Here is a listing of ISO codes on wikipedia

allowsVOIP – Indicates if the carrier allows VoIP calls to be made on its network.

Example:

CarrierInfo Code Sample  Available on gist here

 

CurrentNetwork

CurrentNetwork provides access to the native CNCopyCurrentNetworkInfo object.

SSID – Provides access the SSID the device is currently connected.
BSSID – Provides access the BSSID the device is currently connected.

Example:

Current Network Code Sample Available on gist here

Reachability

The Reachability component provides a wrapper for the Apple Reachability module. For more about Reachability please see the Apple documentation here.

reachabilityForLocalWiFi – This method provides a boolean result if Local Wifi is enabled.
reachabilityWithHostName – This method takes a host name, such as http://www.apple.com and returns a boolean result if the host is reachable.
hostNameReachableBy – This method takes a host name, such as http://www.benCoding.com and returns a constant with how it is reachable.

Example:

Reachability Code Sample  Available on gist here

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s