Monday, March 31, 2014

ِAndroid/IOS Mobile Applications: How do I add URI support to my app?



Part 1: Define the URI structure

First step is to figure out how the URI will look. At minimum, it will look something like this:

com.myshoppingsite://

In URI lingo "shopping" is considered the scheme and is whatever you'd like it to be. So first choose an appropriate scheme. Typically, it will follow something very similar to your app name.

Next is to consider the path after the scheme. In the com.myshoppingsite:// example say if you want to link to a specific product within your app, you can do something like:

com.myshoppingsite://products/123

Here are some more examples of URI schemes that are out there:
http://wiki.akosma.com/IPhone_UR...
http://handleopenurl.com/

Here is a good answer that illustrates how best to go about defining the URI structure:

https://www.quora.com/URIs/What-best-practices-should-I-follow-when-creating-URI-structures-for-mobile-apps/answer/Simon-Tam-5


Part 2: Integrate the scheme into your app

Without getting too technical, here's the quick and dirty version. Please refer here for more a more detailed view:

https://www.sparq.it/web/api/v1/...

IOS devices

1. Define the URI scheme in Info.plist under CFBundleURLTypes -> CFBundleURLSchemes.

2. Implement application:openURL:sourceApplication:annotation: in your app delegate. (handleOpenUrl is deprecated)

3. The full URI will be passed in which you can then parse and handle within your app

Full reference: http://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW50

Android devices

First determine which set of activities will be handling your URIs. For example, say your app can display products and you want your URI to deeplink into them like so:

com.myshoppingsite://products

You will then need to define an intent filter in the AndroidManifest.xml:
Full reference: http://developer.android.com/training/basics/intents/filters.html#AddIntentFilter


No comments:

Post a Comment