kolistivra
kolistivra

Reputation: 4429

Universal links does not work with React Native

I've been using React Native & Branch.io successfully for awhile and it's great. However, I would like to be able to handle non-Branch deeplinks as well. For instance, if my domain name is https://example.com, I'd like my app to be opened when opening, say, https://example.com/my-items. I've been trying to make it work with no luck. I read many, many GitHub issues and SO questions. To repeat, https://example.app.link (i.e. Branch urls/universal links) work without any issues.

Basically, when I click on https://example.com/my-items , my website opens in Safari. The "Open with XYZ" iOS modal does not show up, and I am not taken to the app.

Here's what I've already tried:

0) Went through https://facebook.github.io/react-native/docs/linking and https://hackernoon.com/react-native-deep-linking-for-ios-and-android-d33abfba7ef3

1) Made sure I serve https://example.com/apple-app-site-association (and verified it with https://branch.io/resources/aasa-validator/ ) as JSON and is publicly available.

2) XCode -> Capabilities -> Associated domains

2.1) I also tried with app.link associated d

3) For the sake of debugging, I even made the following in AppDelegate.m (normally I check via [RCTLinkingManager application:application openURL:url options:options] etc)

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

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
{
  return YES;
}

4) I tried on the device itself (using iMessages, Notes, Safari). I also turned off remote debugging (as noted here)

Relevant versions:

XCode: Version 10.2.1 (10E1001)

iOS: 12.4.1

react-native: 0.60.5

react-native-branch: 3.0.0^

https://example.com/apple-app-site-association

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "<MyTeamID-censored>.<My-Bundle-Identifier-censored>", 
        "paths": [
          "/verify-email*",
          "/notifications/borrower-request*",
          "/notifications/request-confirmed*",
          "/messages/*",
          "/verification",
          "/my-items",
          "/my-rentals",
          "/dashboard*"
        ]
      }
    ]
  }
}

Upvotes: 4

Views: 4140

Answers (3)

Shahen Hovhannisyan
Shahen Hovhannisyan

Reputation: 645

In Debug mode it not worked for me as well

Try to change build configuration to release(or other if you have) it should work then

Also you can validate your ASAA file online

Upvotes: 1

user12023578
user12023578

Reputation:

If you just want to use links with your own domain, then you can change your Branch app.link domain to your own custom domain from Link Settings.

Upvotes: 0

Tim
Tim

Reputation: 11

Is this relevant to your use case? It helped me.

When a user is browsing your website in Safari and they tap a universal link to a URL in the same domain as the current webpage, iOS respects the user’s most likely intent and opens the link in Safari. If the user taps a universal link to a URL in a different domain, iOS opens the link in your app.

source

Upvotes: 0

Related Questions