Adding URL Handler to mobile app on iOS

Hi all,

I have been following the instructions on the following web page (http://mobiledevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html) to allow the app to open on following a URL link.

The problem I have is how to implement the entry method which is in Objective-C:

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

{

// Do something with the url here

}

Does anyone know how I would add this either to the java source or to the cross-compiled code?

When I do add this as-is to the MyApplication.mm it does not compile.

Cheers

Ian

Hi Ian,

You can actually do this with the J2ME platform request call. On most platforms it responds to http, https and tel prefixes to launch the browser and dialer.

But on iphone you can launch any app through that method, e.g. for a users profile on Facebook

midlet.platformRequest("fb://profile");

this is an excellent resource: http://wiki.akosma.com/IPhone_URL_Schemes

Cheers,
Matt

Thanks Matt,

That’s good and means I don’t have to modify the Plist file.

My question was more around how to write the handler method as it is always shown in Objective-C and doesn’t compile when I copy it into our cross-compiled files…

Can you help?

Cheers

Ian

Hi Ian,

Our “NativeUIMyNativeElement” or “NativeUIPDFDemo” projects might be useful here. Both these show how to inject native iOS code (and code for other platforms) into Mobile Designer projects. The platform specific code additions can be found in the “native” folders in these projects, and the hookpoint in each project’s “defaults.xml” copies these bits of replacement code into the build chain from the Multi-Build dialog.

Chapter 4 of "NativeUIMyNativeElement\docs_NativeUIMyNativeElement_.pdf" gives more details on how to incorporate these concepts into a new project.

Regards,

Nick.

(Mobile Designer Development Team)