Skip to content

Instantly share code, notes, and snippets.

@anhar
Last active October 17, 2024 01:06
Show Gist options
  • Save anhar/6d50c023f442fb2437e1 to your computer and use it in GitHub Desktop.
Save anhar/6d50c023f442fb2437e1 to your computer and use it in GitHub Desktop.
Setting up iOS Universal Links
@gerardnll
Copy link

gerardnll commented Aug 27, 2021

Bad mime-type in gist, it's 'application/json', application word is repeated:

location /apple-app-site-association {
    default_type application/application/json;
}

@MikeZnnam
Copy link

MikeZnnam commented Jan 8, 2022

Dear colleagues,

I'm struggling now for more than one week at this topic and still it is not working.
I get the following error while apple validation:

Link to Application |
Action requiredCould not extract required information for Universal Links. Learn how to implement the recommended Universal Links. |
Error no apps with domain entitlementsThe entitlement data used to verify deep link dual authentication is from the current released version of your app. This data may take 48 hours to update.

I created apple-app-site-association. See the following link: https://pflanzenkreisel.de/apple-app-site-association/

Within Xcode I configured the following:

  1. URL Types: Identifier:pflanzenkreisel URL Schemas: pflanzenkreisel
  2. applinks:pflanzenkreisel.de was added in associated domains
  3. appDelegate following was added:
#import <React/RCTLinkingManager.h>

- (BOOL)application:(UIApplication *)application
   openURL:(NSURL *)url
   options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  return [RCTLinkingManager application:application openURL:url options:options];
}

// Add this above `@end`:
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
 restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
 return [RCTLinkingManager application:application
                  continueUserActivity:userActivity
                    restorationHandler:restorationHandler];
}

Can you please help me to solve this issue?

Thank you so much!
Mike

@no-toodate
Copy link

thank you !

I am so sorry, I normally don't use MacOS so I am not familiar with objective-C or swift. I really don't know what to do in the 'handle url' parts in the AppDelegate file. What exactly do I need to do? Everytime I am looking at tutorials, I only have "handle this" and I really don't know what to do!

@AlexMoumou
Copy link

AlexMoumou commented Feb 23, 2023

@anhar Hello, this guide was a saviour.

Ive managed to make it work on Safari where a banner pops up on the paths i have specified. It also works through mail apps even if i have a different default browser than Safari. It does not work for Chrome, Firefox or any other browser though.

Is this even possible in iOS or do we have to use a custom scheme which will be called by our site?

Please let me know if anyone else has faced this issue.

Edit: After some testing i found out that it works with default browser Chrome/Firefox if you click a link you support from outside your domain. The following link was very useful in terms of what works from where and when: https://help.branch.io/developers-hub/docs/ios-universal-links

@elomonaco
Copy link

@anhar Hello, this guide was a saviour.

Ive managed to make it work on Safari where a banner pops up on the paths i have specified. It also works through mail apps even if i have a different default browser than Safari. It does not work for Chrome, Firefox or any other browser though.

Is this even possible in iOS or do we have to use a custom scheme which will be called by our site?

Please let me know if anyone else has faced this issue.

Apple assumes you're using Safari, so it won't work with any other browser because Apple thinks of itself and no one else. Honestly whether the app says Chrome, or Firefox or something else, it's really safari under the hood, because Apple strictly prevents another browser engine on the iOS ecosystem, so really your hand is forced to use safari if you want the best experience.

@matthewgallagherskybet
Copy link

@anhar amazing article, covers a lot more caveats than I've seen anywhere else I've looked.

There is one thing I'm a little uncertain on, is it possible to exclude a subdomain using components, or is this done by just not including that subdomain as an applinks option within the apps Associated Domains capability?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment