3

I'm working with universal link in iOS. It is working fine from Safari browser and messages.

Setup Server

I'm having a server running online. To securely associate my iOS app with a server, Apple requires that you make available a configuration file, called apple-app-site-association. This is a JSON file which describes the domain and supported routes.

The apple-app-site-association file needs to be accessible via HTTPS, without any redirects, at https://{domain}/apple-app-site-association.

The file looks like this:

{
    "applinks": {
        "apps": [],
        "details": [
        {
            "appID": "**********.com.domain.appname”,
                "paths": ["*"]
        }
        ]
    }
}

NOTE - I'm not append .json to the apple-app-site-association filename.

And successfully setup the iOS application also.

My requirement is, I shared the link from my app to Facebook. When users tap the link from Facebook, It should open the app when the app is available on the phone or it should be opened from the browser.

Now my problem is:

Step 1: I shared the link from my App to Facebook.

Step 2: I logged in Facebook from Safari. When I tap the link, it is successfully opens my app.

Step 3: If I do the same in Facebook app. It is opening in inside the Facebook web view. But I need it to be open my app.

halfer
  • 18,701
  • 13
  • 79
  • 158
Sabs
  • 1,148
  • 2
  • 16
  • 46
  • I have written a detailed solution document under this question: https://stackoverflow.com/questions/46266797/deeplink-solution-for-ios-and-android-apps-works-in-facebook – Mustafa Atalar Sep 17 '17 at 18:26

2 Answers2

8

This is a very common issue: the Facebook app does not support Universal Linking out of the app. As you are seeing, you will wind up in the webview every time. This is an issue with many apps that force web content to be opened in captive webviews. Some apps, such as Slack, do provide a setting to open web content in Safari instead of the captive webview. The Facebook app does not provide this option.

The best user experience I have seen for this type of situation is to present your own web page in the webview. The web page presented has a Universal Link, and by tapping this link users are able to open your app.

Branch handles the requirement for this additional web page by providing their partners with "Deepviews" (see: https://dev.branch.io/features/deepviews/overview/). You could of course create something similar yourself.

dwestgate
  • 961
  • 5
  • 12
  • 1
    Also beware that you'll need two different domains in order to get it working correctly. See https://stackoverflow.com/questions/33554973/ios-9-universal-links-not-launching-the-app-from-the-same-domain and confirmation of this as "There are a bunch of caveats to get this to work. For example, the Universal Link cannot be the same domain that the user is currently viewing." in https://blog.branch.io/how-to-deep-link-off-of-facebook-in-2016/ – Alexis Pautrot Oct 02 '18 at 10:35
0

it handled via

func application(_ application: UIApplication, open url: URL, sourceApplication:   String?, annotation: Any) -> Bool {
    print(url)
}

/// parser function
func parseFBAppLinks(from url: URL) -> String? {
   guard let components = URLComponents(url: url, resolvingAgainstBaseURL: true)  else { return .none }
   guard let urlString = components.queryItems?.first?.value else { return .none }

   return urlString
}
Leonif
  • 429
  • 4
  • 14