Skip to content

Commit 0148e86

Browse files
author
Klevis X.
committed
Add Swift integration instructions for deep linking
1 parent 60212e4 commit 0148e86

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

versioned_docs/version-7.x/deep-linking.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ function App() {
7272

7373
return (
7474
<NavigationContainer linking={linking} fallback={<Text>Loading...</Text>}>
75-
{/* content */}
76-
</NavigationContainer>
77-
);
78-
}
75+
{/* content */
7976
```
8077
8178
</TabItem>
@@ -127,6 +124,28 @@ If your app is using [Universal Links](https://developer.apple.com/ios/universal
127124
}
128125
```
129126

127+
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).
128+
129+
```swift
130+
// Add this to your AppDelegate.swift file
131+
132+
import React
133+
134+
@UIApplicationMain
135+
class AppDelegate: UIResponder, UIApplicationDelegate {
136+
var window: UIWindow?
137+
138+
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
139+
return RCTLinkingManager.application(application, open: url, options: options)
140+
}
141+
142+
// For Universal Links
143+
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
144+
return RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
145+
}
146+
}
147+
```
148+
130149
Now you need to add the scheme to your project configuration.
131150

132151
The easiest way to do this is with the `uri-scheme` package by running the following:

0 commit comments

Comments
 (0)