O'Reilly logo

Professional iPhone® Programming with MonoTouch and .NET/C# by Rory Blyth, Chris Hardy, Craig Dunn, Martin Bowling, Wallace B. McClure

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Talking to Other Applications

WHAT'S IN THIS CHAPTER?

  • Making MonoTouch talk with other applications with the OpenURL method

  • Having your applications integrate with third-party applications

  • Accessing the iPhone Address Book or the iPod music library

  • Integrating with third-party libraries with Objective-C and .NET

This chapter discusses the ways you can use MonoTouch to talk to other applications on the iPhone, both Apple-built applications and those downloaded from the App Store. It also provides helpful ways of accessing the iPhone's Address Book and the iPod music library.

The secret behind interfacing with any application on the device is the OpenUrl method on the current UIApplication, which can be accessed via UIApplication.SharedApplication. This method handles where and what to open when you pass in an NSUrl object for it to parse. When the method is called, the app closes in its normal fashion by calling the WillTerminate method as it closes and carries out the appropriate action based on the URL passed in.

INTEGRATING APPLE APPLICATIONS

This section shows how you can integrate Apple-built applications into your own application.

Opening Up Safari

Opening up Safari is a pretty straightforward place to start. The most likely reason for you to close down your app and open up Safari is because you would like a web site to be displayed. The web site URL is the NSUrl object that you pass into the OpenUrl method:

var url = NSUrl.FromString("http://wrox.com"); UIApplication.SharedApplication.OpenUrl(url); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required