Skip to Content

What is an app URL scheme?

What is an app URL scheme?

An app URL scheme is a way for apps on a mobile device like an iPhone or Android phone to interact with each other. It allows one app to launch or communicate with another app on the device by calling a special URL. Some common examples of URL schemes are:

  • sms:// – Used to launch the messages app to compose a new text message
  • mailto:// – Used to launch the email app to compose a new email
  • maps:// – Used to launch the maps app and show a specific location
  • youtube:// – Used to launch the YouTube app and open a specific video

App URL schemes follow a basic structure:

app://path?query_parameters

Where:

  • app – The unique app name that defines the URL scheme
  • path – An optional path to a resource within the app
  • query_parameters – Optional query string parameters

For example:

sms://?body=Hello%20there

Would launch the messages app and prefill a new text message with the text “Hello there”.

How do app URL schemes work?

App URL schemes work by registering a custom protocol with the operating system that links to the app. For example, the YouTube app registers the youtube:// protocol to launch itself.

When another app calls a URL with the youtube:// scheme, the operating system looks up the registered app for that scheme and launches the YouTube app. The YouTube app can then interpret the full URL to know what action to take.

App URL schemes provide a way for apps to integrate tightly with each other for easy content sharing. The user experience is seamless without having to copy/paste content between apps.

Why are app URL schemes useful?

Here are some of the main uses and benefits of app URL schemes:

  • Launching apps – A URL scheme provides a way to launch or open another app from your own app. For example, calling the youtube:// URL would launch the YouTube app.
  • Deep linking – URL schemes allow you to link directly into the content within another app. For example, you could link directly to a YouTube video bypassing the YouTube app homepage.
  • Sharing content – Easily share content like text, images, files, locations etc. from your app into the receiving app. For example, sharing an article link into a messenger app.
  • App-to-app communication – Enables apps to communicate directly with each other to coordinate workflows. For example, a payment app communicating with a merchant app.
  • Custom actions – Apps can define custom actions to perform within their app via URL schemes. For example, a “redeem coupon” action.

By leveraging URL schemes, apps can provide much tighter integration and connect their user experiences together in a seamless way.

How to register a custom URL scheme

To use a custom app URL scheme, it first needs to be defined and registered with the operating system. Here is an overview of how to register a URL scheme:

iOS

On iOS, define the URL schemes in your app’s Info.plist file under the “LSApplicationQueriesSchemes” key. For example:


<key>LSApplicationQueriesSchemes</key>
<array>
<string>customscheme</string>
</array>

This will register your app as the handler for the “customscheme://” URL scheme.

Android

On Android, add an to your AndroidManifest.xml file for your URL scheme:


<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="customscheme" />
</intent-filter>

This registers your app to handle links with the “customscheme://” scheme.

Once registered, you can call openURL() on iOS or startActivity() on Android from your app passing in your custom URL scheme to launch your app.

Common URL schemes

Here are some of the most popular and commonly used URL schemes for mobile apps:

App URL Scheme
YouTube youtube://
Apple Maps maps://
Google Maps comgooglemaps://
App Store itms://
Phone / SMS tel://, sms://
Email mailto://
WhatsApp whatsapp://
Instagram instagram://
Facebook fb://
Twitter twitter://

These schemes can be used to launch or share content into their respective apps from your own app. Each app may support additional custom paths and parameters as part of their URL scheme for deeper integration.

Examples

Here are some examples of using app URL schemes:

Launch YouTube and play video


youtube://watch?v=video_id

Get directions in Apple Maps


maps://?saddr=Current%20Location&daddr=San%20Francisco

Compose email in Mail app


mailto:[email protected]&subject=Hello&body=How%20are%20you%3F

Send WhatsApp message


whatsapp://send?text=Hello%2C%20World!

Open product page in Amazon app


amazon://www.amazon.com/dp/product_id

Security considerations

Although app URL schemes provide useful functionality, there are some security risks to consider:

  • Any app can potentially access registered URL schemes, so sensitive schemes should be guarded.
  • URL schemes may give apps access to information or actions users don’t intend.
  • Malicious apps could use URL schemes to access private data in other apps.
  • Apps should validate incoming URLs to prevent abuse.
  • User should be prompted to confirm sharing sensitive data like contacts.

Here are some best practices around security with URL schemes:

  • Only register URL schemes when they need to be public.
  • Validate incoming URLs have an allowed host or source app.
  • Use schemes with random strings like “yourapp://xdfskl234” to prevent access from other apps.
  • Use ephemeral schemes that change periodically.
  • Only support very specific use cases from other apps.

Overall app URL schemes require balancing usability with security. Handled carefully, they provide a great way to improve integration between apps.

Conclusion

App URL schemes are an invaluable tool for iOS and Android developers. They enable apps to interact with each other to share data, launch screens, and handle workflows between different apps.

Some best practices are to document your custom schemes, validate incoming URLs, and implement appropriate security measures. URL schemes open up many possibilities for new features and better app integrations. Leveraging schemes thoughtfully can greatly improve the user experience in your apps.