From 0148e8678b4b937c1a4f79162eb4ddaa84ce0f41 Mon Sep 17 00:00:00 2001 From: "Klevis X." Date: Wed, 14 May 2025 13:43:19 +0200 Subject: [PATCH 1/3] Add Swift integration instructions for deep linking --- versioned_docs/version-7.x/deep-linking.md | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/versioned_docs/version-7.x/deep-linking.md b/versioned_docs/version-7.x/deep-linking.md index 6b6389861f..fe9eee2450 100755 --- a/versioned_docs/version-7.x/deep-linking.md +++ b/versioned_docs/version-7.x/deep-linking.md @@ -72,10 +72,7 @@ function App() { return ( Loading...}> - {/* content */} - - ); -} + {/* content */ ``` @@ -127,6 +124,28 @@ If your app is using [Universal Links](https://developer.apple.com/ios/universal } ``` +If you're using Swift, you'll need to add the following to your `AppDelegate.swift` file. You can find more information in the [React Native documentation](https://reactnative.dev/docs/linking?ios-language=swift). + +```swift +// Add this to your AppDelegate.swift file + +import React + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + var window: UIWindow? + + func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { + return RCTLinkingManager.application(application, open: url, options: options) + } + + // For Universal Links + func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { + return RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler) + } +} +``` + Now you need to add the scheme to your project configuration. The easiest way to do this is with the `uri-scheme` package by running the following: From ac132fcebb6eceb6f0e160e572ccfea44cd0c8c7 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Sun, 27 Jul 2025 23:27:41 +0200 Subject: [PATCH 2/3] Use tabs and split universal link snippet for swift --- versioned_docs/version-7.x/deep-linking.md | 67 +++++++++++++--------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/versioned_docs/version-7.x/deep-linking.md b/versioned_docs/version-7.x/deep-linking.md index fe9eee2450..9e4895f239 100755 --- a/versioned_docs/version-7.x/deep-linking.md +++ b/versioned_docs/version-7.x/deep-linking.md @@ -72,7 +72,10 @@ function App() { return ( Loading...}> - {/* content */ + {/* content */} + + ); +} ``` @@ -96,13 +99,23 @@ const linking = { Let's configure the native iOS app to open based on the `example://` URI scheme. -You'll need to link `RCTLinking` to your project by following the steps described here. To be able to listen to incoming app links, you'll need to add the following lines to `AppDelegate.m` in your project: +You'll need to add the LinkingIOS folder into your header search paths as described [here](https://reactnative.dev/docs/linking-libraries-ios#step-3). Then you'll need to add the following lines to your or `AppDelegate.swift` or `AppDelegate.mm` file: + + + + +```swift +override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { + return RCTLinkingManager.application(app, open: url, options: options) +} +``` + + + ```objc -// Add the header at the top of the file: #import -// Add this inside `@implementation AppDelegate` above `@end`: - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options @@ -111,10 +124,31 @@ You'll need to link `RCTLinking` to your project by following the steps describe } ``` + + + If your app is using [Universal Links](https://developer.apple.com/ios/universal-links/), you'll need to add the following code as well: + + + +```swift +override func application( + _ application: UIApplication, + continue userActivity: NSUserActivity, + restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { + return RCTLinkingManager.application( + application, + continue: userActivity, + restorationHandler: restorationHandler + ) + } +``` + + + + ```objc -// Add this inside `@implementation AppDelegate` above `@end`: - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler { @@ -124,27 +158,8 @@ If your app is using [Universal Links](https://developer.apple.com/ios/universal } ``` -If you're using Swift, you'll need to add the following to your `AppDelegate.swift` file. You can find more information in the [React Native documentation](https://reactnative.dev/docs/linking?ios-language=swift). - -```swift -// Add this to your AppDelegate.swift file - -import React - -@UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate { - var window: UIWindow? - - func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { - return RCTLinkingManager.application(application, open: url, options: options) - } - - // For Universal Links - func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { - return RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler) - } -} -``` + + Now you need to add the scheme to your project configuration. From 138bb7ec091510a70f9d79269d89486d731bea61 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Sun, 27 Jul 2025 23:28:41 +0200 Subject: [PATCH 3/3] Fix typo --- versioned_docs/version-7.x/deep-linking.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versioned_docs/version-7.x/deep-linking.md b/versioned_docs/version-7.x/deep-linking.md index 9e4895f239..5a9a48a506 100755 --- a/versioned_docs/version-7.x/deep-linking.md +++ b/versioned_docs/version-7.x/deep-linking.md @@ -99,7 +99,7 @@ const linking = { Let's configure the native iOS app to open based on the `example://` URI scheme. -You'll need to add the LinkingIOS folder into your header search paths as described [here](https://reactnative.dev/docs/linking-libraries-ios#step-3). Then you'll need to add the following lines to your or `AppDelegate.swift` or `AppDelegate.mm` file: +You'll need to add the `LinkingIOS` folder into your header search paths as described [here](https://reactnative.dev/docs/linking-libraries-ios#step-3). Then you'll need to add the following lines to your or `AppDelegate.swift` or `AppDelegate.mm` file: