Tuesday, May 31, 2011

How do I retrieve the phone number from the iPhone?

When Apple installs an application on the iPhone, it creates a symbolic link to a file /private/var/mobile/Library/Preferences/.GlobalPreferences.plist from Library/Preferences. Inside the plist is an entry called SBFormattedPhoneNumber.

So, in order to retrieve the phone number, simply do this

NSString *iPhoneNumber = [[NSUserDefaults standardUserDefaults] objectForKey:@"SBFormattedPhoneNumber"]

How can I know if my iOS device supports phone calls?

The easiest way is to check if the tel:// protocol is supported on the device

[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]];

canOpenURL: explicitly checks whether there's an application capable of opening that URL scheme, not that the URL is correct.

How to get the UDID from the iOS platform

We get many requests from the businesses that want to know some information from the user for risk management purposes. Here is the way to get the UDID from the iOS device

NSString * udid = [[UIDevice currentDevice] uniqueIdentifier];

Tuesday, May 17, 2011

iOS orientation at launch

You can name your start up images specifically for the orientation and each one will be displayed for that orientation

Default-Portrait.png
Default-PortraitUpsideDown.png
Default-Landscape.png
Default-LandscapeLeft.png
Default-LandscapeRight.png

As far as the device is concerned the orientation is portrait while the application is launching. At some point after application:didFinishLaunchingWithOptions: it will detect the different orientation and call your shouldAutorotateToInterfaceOrientation: method and then your other view rotation methods, which you should handle as normal

Take a look at [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft] if you want to set a vie to landscape