Archive for the ‘iPhone SDK Tutorials’ category

iPhone Developer Spots Facebook Integration in OS 4 SDK

April 20th, 2010

iPhone OS 4 and it’s SDKs were released for the paid iPhone developers on 8, April 2010. Since then iPhone application developers have been digging into SDKs; After spotting the iChat client services earlier with front facing camera libraries, now, Facebook integration has been spotted by Gunning for Safety (which, amazingly, seems to have two areas of interest: nail guns, and iPhone OS).

According to that blog, Apple is probably working on Facebook’s Event Calendar, Contacts to integrate with Calendar, Contacts app on iPhone, respectively. Currently, iPhone has easy setup options for you to setup your accounts on Gmail, MobileMe, Yahoo, etc. You can simply type in your details and you’re done. Facebook, might get listed in this as well.

There was a huge user request received by Joe Hewitt (iPhone Application Developer of Facebook) during development of Facebook 3.0 for iPhone. So, it might be possible that on the other hand Facebook team will work on existing Facebook App to get the proper end user integration.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • N4G
  • Twitter
  • Yahoo! Buzz
Tags: Facebook, Gunning for Safety, iphone develop, iPhone Developer News, iphone developers, iphone OS 4, iPhone OS 4.0, news, OS 4 SDK

Memory Issues in iPhone OS 3.0 : Sample Code

August 26th, 2009

As mentioned in a previous article by Rama Krishna the memory issues in iPhone OS 3.0 relating to UIImageView can be reproduced easily. And here is such a re-production. You can download the iPhone sample application and see for yourself what the problem is. Just open the project, build it for the device (not the simulator) and run it with Instruments (ObjectAlloc) to see a nice little upwards running ramp developing on screen.

Oh!! but remember to run the app on iPhone OS 3.0 and not on iPhone OS 3.1 (the bug has apparently been patched for this version)

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • N4G
  • Twitter
  • Yahoo! Buzz
Tags: iPhone App Developers, iPhone app Developers help, iPhone Application sample code, iPhone OS 3.0, iPhone OS 3.0 issues, iPhone OS Bugs

Custom URL schemes and Launching other applications — Best Practices for iPhone OS 3.0

August 24th, 2009

How to open other applications like phone dialer, SMS, Safari, Google Maps, iTunes or AppStore or any other iPhone application?

“openURL” is the API to use to achieve any of the above and many more.
If you need to let your application users quickly dial APPLE from within your app, just include the following line

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:8006927753"]];

Similarly, you could initiate SMS application by using openURL with “sms: “, but unfortunately you cannot fill in the SMS content as Apple does not yet support it.
There are many more things you could do with this API like launching Google Maps, Safari with any website like you want or even the AppStore links to your apps which you want the users to buy.

Checking support for URLs of other applications
Until the release of iPhone OS 3.0 it was not possible to find if there are any applications installed on the device which handle the URL scheme you are about to use. But now it is possible through the following API

- (BOOL)canOpenURL:(NSURL*)url

Call the above API before using “openURL” to make sure your call will “certainly” be handled by a registered application. If you were developing an iphone app which lets a phone call be made from within it, do the following

// this will fail if the device is an iPod
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel:111"]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:111"]];
}
else
{
// show an Alert here indicating that the call can’t be completed
}

Apart from using “canOpenURL”, do check the return value from “openURL” too and take appropriate action.

You should also use “canOpenURL” to find out if any features (like calling a number and SMS) that are not accessible on iPod should be disabled or hidden. Showing “phone” icons and letting them be clicked in your application on an iPod is a sure shot way to get your application rejected for uploading to AppStore.

Registering and handling custom URL schemes
If you are developing a great tool and can be used by other applications, you can register custom URL schemes and implement them. To create custom URL schemes just add them to your application’s “info.plist” file.

  • To the root element of your application’s “info.plist” file, add a row with key named “URL types”.
  • Expand it to find “item1″ in it, expand it and edit the value for key “URL identifier” to look something like “com.yourcompany.yoururlscheme”
  • Add another row to “item1″ with key “URL Schemes”. Type in the first few characters of your URL scheme.
    For an example, if you wish to use url formats like abc://part1/part2, just enter “abc” for URL Schemes

Once you have created and registered your own URL formats/schemes, you can handle incoming URL requests by implementing the following UIApplicationDelegate method

- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url

Before parsing and/or handling the URL, make sure it is in the right format and follows all rules of your URL scheme.

The above method was the only place where you can handle incoming URLs until iPhone OS 3.0 arrived. For iPhone OS 3.0 and above, the preferred place to handle incoming URLs is

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions

This method should return whatever “handleOpenURL” API would have returned if it were implemented. If you implement the above delegate method of UIApplication, IPhone OS will not invoke the following methods

- (void)applicationDidFinishLaunching:(UIApplication*)application
- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • N4G
  • Twitter
  • Yahoo! Buzz
Tags: Best Practices for iPhone OS 3.0, iPhone App Developers, iPhone app Developers help, iPhone App Development, iPhone Custom URL schemes, iPhone OS 3.0, iPhone SDK Help

Effective ways of handling Interruptions in iPhone App Development

August 18th, 2009

It is a known and acknowledged fact that user’s experience with your iPhone app is of paramount importance in keeping them glued to it. Towards that, handling interruptions gracefully in an iPhone app plays a key role.

iPhone being a “one app at a time” device, apps get interrupted by incoming Phone Calls, SMSs, Calendar Events, Alarms or Push Notifications from other apps on the device.
The iPhone SDK provides a few methods in UIApplicationDelegate which can be implemented to handle the interruptions and keep user’s experience as flawless/seamless as possible.

The Interruption
- (void)applictaionWillResignActive:(UIApplication*)application

This method lets your application know that it is about to be interrupted by the iPhone OS. The name of the method suggests that your app will no longer be active, and will not respond to any user actions until the interruption is taken care of. An interruption like an incoming phone call or an SMS can either be accepted or dismissed by the user, and this is where you have to perform all tasks necessary to resume if the user chooses to leave the application. If the app was a game, it could save any game state needed for a resumption later.

The Resumption / Interruption Dismissed
- (void)applicationDidBecomeActive:(UIApplication*)application

When your application is about to become active again, this method is called by the iPhone OS. If the user decides not to leave the application and dismisses the interruption this is a good place to allow the user resume using the application. Since the application has not yet been closed, all the required state to resume is still in memory and continuing using the app is really as simple as a Pause/Resume feature.

The Interruption Accepted
- (void)applicationWillTerminate:(UIApplication*)application

If the user decides to leave the application or accepts an interruption, this method call from the iPhone OS notifies us of that intention. This is the place where you save all necessary state of the app/game to resume later.

The best place to save all game/app state to resume later is “applicationWillResignActive”. The simple reason being, all iPhone interruptions need user’s input to either accept or dismiss the interruption. This action from the user might needs a few seconds of his/her time to understand what the interruption is and what to do with it. This duration should be just enough for a well written application to save all state. Whereas, in the case of the application being closed by the user, iPhone OS wouldn’t wait for the app to complete saving state. The time available is really short and many applications might fail to save state.

Since there are multiple reasons and ways for an app being closed, state saving method calls need to be placed both in “applictaionWillResignActive” and “applictaionWillTerminate”. But ensure you don’t waste precious time in saving app state at both places. If the user closes the application by pressing the “Home” button, use “applictaionWillTerminate” to save state and necessary cleanups. If the application is being closed due to an interruption, save state in “applictaionWillResignActive” and perform any necessary cleanup in “applictaionWillTerminate”.

So, make it a point to use various UIApplicationDelegate methods to maintain user experience and reusability of the app. Keep your users glued to your application or game and return to it after an interruption.

For more tips and strategies on iPhone App Development, click here. For iPhone app marketing tips, try this link.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • N4G
  • Twitter
  • Yahoo! Buzz
Tags: iPhone App Development, iPhone Development help, iPhone Development tips, iPod Touch Development tips