How to Use App Links for iOS/Android Apps and Facebook Sharing

Manish Singh
3 min readApr 22, 2023

As an iOS app developer, you want to provide your users the best possible user experience. One way to achieve this is by using App Links, a powerful feature that allows you to deep link to specific content in your iOS app from other apps and websites. With App Links, you can create links that open your app directly to specific content, such as a product page or a news article, instead of just opening the app’s home screen.

In addition to deep linking, App Links also enable easy sharing of content on Facebook. When someone shares content from your app on Facebook, the shared post can include a link that, when clicked, opens your app directly to the shared content. This is a great way to increase visibility and engagement for your app.

To use App Links in your iOS app, you’ll need to define a custom URL scheme for your app. A URL scheme is a unique identifier that allows other apps and websites to launch your app and pass data to it. Here’s how you can define a custom URL scheme for your app:

1. In Xcode, open your app’s Info.plist file.
2. Add a new key called “URL types” if it doesn’t already exist.
3. Under “URL types”, add a new item and give it a unique identifier, such as “com.yourcompany.yourapp”.
4. Add a new sub-item called “URL schemes” under the new item.
5. Set the value of “URL schemes” to a unique identifier that represents your app, such as “yourapp”.
6. Save the changes to your Info.plist file.

Now that you’ve defined a URL scheme for your app, you can use it to create App Links that deep link to specific content in your app. To create an App Link, you’ll need to define a custom URL that includes your app’s URL scheme and any additional parameters that you want to pass to your app. For example, if your app’s URL scheme is “yourapp”, you could create an App Link that deep links to a product page in your app with the following URL:

yourapp://product?id=1234

When a user clicks on the App Link, iOS will launch your app and pass the URL and any additional parameters to your app. You can then use this data to open the appropriate content in your app.

To ensure that your App Links are properly detected and indexed by Facebook and other apps and websites, you should also include the `al:web:url` meta tag in your HTML code. This meta tag specifies the canonical URL for the content being shared and tells Facebook which URL is the official URL for the content.

When someone shares content from your app on Facebook, the shared post can include a link that, when clicked, opens your app directly to the shared content. To enable this, you’ll need to implement the following in your app:

  1. In your app’s AppDelegate, implement the application(_:didFinishLaunchingWithOptions:) method.
    2. In this method, check the launch options for a URL with your app’s custom URL scheme.
    3. If a URL with your app’s custom URL scheme is found, parse the URL and open the appropriate content in your app.
    4. If a URL with your app’s custom URL scheme is not found, continue with the normal app launch.

In addition to the above, you will also need to add the following meta tags to your web page. These meta tags are important for facebook to determine how to handle your applink.

iOS Version

<meta property=”al:ios:url” content=”yourapp://content/link”>
<meta property=”al:ios:app_store_id” content=”your_app_store_id”>
<meta property=”al:ios:app_name” content=”Your App Name”>
<meta property=”al:web:url” content=”https://yourwebsite.com">

Android Version

<meta property=”al:android:url” content=”yourapp://content/link”>
<meta property=”al:android:package” content=”yourapp.package.name”>
<meta property=”al:android:app_name” content=”Your App Name”>
<meta property=”al:web:url” content=”https://yourwebsite.com">

Once you have added these tags to your web content you https://developers.facebook.com/tools/debug to debug through facebook scrape tool to determine how your facebook debug tool is reading your content and if there is any issue with the meta tags. If meta tags are fine, you should see the following tags in the debugger.

al:ios

[
{
"url": "yourapp://",
"app_name": "Your App Name App"
}
]

al:web

{
"url": "https://gymsheet-491b7.web.app/",
"should_fallback": true
}

With this implementation, when someone clicks on a shared post on Facebook that includes an App Link to your app, the app will open directly to the shared content.

In conclusion, App Links are a powerful feature that can greatly enhance the user experience in your iOS app.

--

--