Deep Linking — Setup for iOS

JAA Consulting
2 min readFeb 17, 2023

--

To increase the traffic on your application, the user should come to your app from an external source. You should be able to share your app content through links on social platforms, and when the user clicks on those links, you want your app to handle those links and take the user directly to the intended content screen. Well, that’s what the Deep Link is for.

I will walk you through how to set DeepLink for your react-native app on iOS.

Update AppDelegate.m

Navigate to AppDelegate.m file under the iOS folder on your react-native app and add the following code below.

// Add the header at the top of the file:
#import <React/RCTLinkingManager.h>

// Add this inside `@implementation AppDelegate` above `@end`:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [RCTLinkingManager application:application openURL:url options: options];
}

By following the step above, we link RCTLinking to your project, and also your app can know listing for incoming app links.

Setup Scheme (uri-scheme)

You can add a uri-scheme to your project by running the command below or manually adding a new URL Type through Xcode. In my case, the uri-scheme will be recharge.

npx uri-scheme add recharge --ios

However, you can easily add manually by opening your project on Xcode, then under the Info tab, add url scheme for your app. URL Schemes allow iOS to figure out which screen to open based on the deep link you provide. For example, I name my URL Scheme Jlrecharge but choose yours carefully because it is always the prefix of your deep link everywhere you use it.

Validate DeepLink

Now you should test your deep link to confirm everything is working correctly. You can do it by running the command below.

`npx uri-scheme open jlrecharge://home — ios`

Before you test your deep link, I recommend rebuilding your iOS project, uninstalling the app, and install again. The first time when I ran the command above, I got the following error below.

jalves@Justimianos-MacBook-Pro jlrecharge % npx uri-scheme open “jlrecharge://welcome” — ios
› iOS: Opening URI “jlrecharge://welcome” in simulator
An error was encountered processing the command (domain=NSOSStatusErrorDomain, code=-10814):
The operation couldn’t be completed. (OSStatus error -10814.)

For Support or if you have any question, please reach out.

If you have questions or need help, reach out — info@jaalves.com.

Collaboration:

DM on Instagram : https://www.instagram.com/jaa.consulting/

DM on Facebook: https://www.facebook.com/Jaa.Consulting.Official

--

--

JAA Consulting

Over decade of experience building software and support entire live-cycle of development.