docs(react-native): update deep link setup instructions#668
docs(react-native): update deep link setup instructions#668victoreronmosele wants to merge 3 commits intokinde-oss:mainfrom
Conversation
WalkthroughUpdated the React Native SDK documentation to remove manual Android native-linking, declare required dependencies centrally, and modernize iOS integration with CocoaPods and language-aware (Swift/Objective-C) AppDelegate tabbed examples; deep linking guidance was restructured into platform-specific, tabbed instructions. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/content/docs/developer-tools/sdks/native/react-native-sdk.mdx`:
- Around line 235-253: The code calls
authorizationFlowManagerDelegate.resumeExternalUserAgentFlow(with:) using
userActivity.webpageURL which is an optional; update the
AppDelegate.application(_:continue:restorationHandler:) branch to safely unwrap
the URL (e.g., if let url = userActivity.webpageURL) and pass the non-optional
url to delegate.resumeExternalUserAgentFlow(with:), only returning true when
both the delegate exists and the unwrapped url is passed; keep the fallback to
RCTLinkingManager.application(...).
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/content/docs/developer-tools/sdks/native/react-native-sdk.mdx (2)
275-284: Inconsistent nil-guard onauthorizationFlowManagerDelegateacross ObjC handlers.The custom-scheme handler (line 280) calls
resumeExternalUserAgentFlowWithURL:directly onself.authorizationFlowManagerDelegatewithout a nil-check, while the universal-link handler (line 295) wraps the same call inif (self.authorizationFlowManagerDelegate). Messagingnilin Objective-C is safe and returnsNO, so there is no crash risk, but for consistency either pattern should be applied uniformly.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/content/docs/developer-tools/sdks/native/react-native-sdk.mdx` around lines 275 - 284, The custom-scheme handler method application:openURL:options: calls [self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url] without a nil-check; make this consistent with the universal-link handler by first checking self.authorizationFlowManagerDelegate before invoking resumeExternalUserAgentFlowWithURL: (i.e., only call resumeExternalUserAgentFlowWithURL: if self.authorizationFlowManagerDelegate is non-nil and return YES when it returns YES, otherwise fall back to calling RCTLinkingManager application:openURL:options:).
261-263:RCTLinkingManager.himport belongs inAppDelegate.m, notAppDelegate.h.
RCTLinkingManageris only referenced in the.mimplementation methods. Importing it in the public.hheader needlessly widens the visible interface. Moving it to the.mfile follows the standard Objective-C convention of importing symbols where they are used.♻️ Proposed refactor
// AppDelegate.h + `#import` <React/RCTLinkingManager.h> ← remove from here `#import` "RNAppAuthAuthorizationFlowManager.h"// AppDelegate.m (add at the top of the file) + `#import` <React/RCTLinkingManager.h>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/content/docs/developer-tools/sdks/native/react-native-sdk.mdx` around lines 261 - 263, The import of RCTLinkingManager.h should be removed from AppDelegate.h and added to AppDelegate.m where the linking methods are implemented; update the header to only include RNAppAuthAuthorizationFlowManager.h (or other public headers) and move `#import <React/RCTLinkingManager.h>` into AppDelegate.m near the implementation of the methods that reference RCTLinkingManager to keep the public interface clean and follow Objective-C import conventions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/content/docs/developer-tools/sdks/native/react-native-sdk.mdx`:
- Around line 186-202: The bridging header guidance is incomplete: ensure
AppDelegate+RNAppAuth.h (or your existing Objective-C Bridging Header) also
imports RCTLinkingManager so Swift can call RCTLinkingManager methods used by
RNAppAuth; add `#import` <React/RCTLinkingManager.h> alongside the existing
RNAppAuthAuthorizationFlowManager import, and update Step 2 to instruct
developers to add these imports to their existing bridging header instead of
replacing it if one already exists.
---
Duplicate comments:
In `@src/content/docs/developer-tools/sdks/native/react-native-sdk.mdx`:
- Around line 235-254: The conditional previously passed an optional to a
non-optional parameter; update the AppDelegate
application(_:continue:restorationHandler:) to safely unwrap
userActivity.webpageURL in the if-chain and pass the unwrapped url to
authorizationFlowManagerDelegate.resumeExternalUserAgentFlow(with:), as shown by
the new let url = userActivity.webpageURL check and the call to
resumeExternalUserAgentFlow(with: url); if that returns false, fall back to
RCTLinkingManager.application(..., continue: userActivity, restorationHandler:
restorationHandler).
---
Nitpick comments:
In `@src/content/docs/developer-tools/sdks/native/react-native-sdk.mdx`:
- Around line 275-284: The custom-scheme handler method
application:openURL:options: calls [self.authorizationFlowManagerDelegate
resumeExternalUserAgentFlowWithURL:url] without a nil-check; make this
consistent with the universal-link handler by first checking
self.authorizationFlowManagerDelegate before invoking
resumeExternalUserAgentFlowWithURL: (i.e., only call
resumeExternalUserAgentFlowWithURL: if self.authorizationFlowManagerDelegate is
non-nil and return YES when it returns YES, otherwise fall back to calling
RCTLinkingManager application:openURL:options:).
- Around line 261-263: The import of RCTLinkingManager.h should be removed from
AppDelegate.h and added to AppDelegate.m where the linking methods are
implemented; update the header to only include
RNAppAuthAuthorizationFlowManager.h (or other public headers) and move `#import
<React/RCTLinkingManager.h>` into AppDelegate.m near the implementation of the
methods that reference RCTLinkingManager to keep the public interface clean and
follow Objective-C import conventions.
| 1. Create a new file, `AppDelegate+RNAppAuth.h`, in the **same folder as your `AppDelegate.swift`** and add the following code: | ||
|
|
||
| ```objc title="AppDelegate+RNAppAuth.h" | ||
| #import "RNAppAuthAuthorizationFlowManager.h" | ||
| ``` | ||
|
|
||
| 2. Set the Objective-C Bridging Header path in your Xcode Build Settings to `$(SRCROOT)/$(TARGET_NAME)/AppDelegate+RNAppAuth.h`. | ||
|
|
||
| <details> | ||
| <summary>Open for steps</summary> | ||
|
|
||
| - Open the project in Xcode. | ||
| - Select the project in the navigator, then the app target. | ||
| - Open the **Build Settings** tab. | ||
| - Search for **bridging**. | ||
| - Set **Objective-C Bridging Header** to $(SRCROOT)/$(TARGET_NAME)/AppDelegate+RNAppAuth.h. | ||
| </details> |
There was a problem hiding this comment.
Missing #import <React/RCTLinkingManager.h> in the bridging header — build will fail.
AppDelegate+RNAppAuth.h only imports RNAppAuthAuthorizationFlowManager.h, but RCTLinkingManager is called directly in both the custom-scheme and universal-link Swift methods added in Step 3. Without exposing that header to Swift, the project won't compile.
React Native App Auth's own docs note that a bridging header is needed to bridge the Objective-C code the package uses, and AppDelegate+RNAppAuth.h is the file to create. That file must also include every header you'll be referring to from Swift code — for React Native, the fundamental headers come from the React static library and need to be explicitly listed, including #import <React/RCTLinkingManager.h>.
Additionally, Step 2 instructs developers to replace the Objective-C Bridging Header setting with this new file. Projects that already have a bridging header configured (common in customised RN projects) will lose those imports. The instructions should clarify: if a bridging header already exists, add the import(s) to that existing file instead of creating a new one and changing the path.
🐛 Proposed fix for the bridging header content
```objc title="AppDelegate+RNAppAuth.h"
+ `#import` <React/RCTLinkingManager.h>
`#import` "RNAppAuthAuthorizationFlowManager.h"</details>
And add a note alongside Step 2, e.g.:
> **Note:** If your project already has an Objective-C Bridging Header configured, add the above imports to that existing file rather than creating a new one.
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against the current code and only fix it if needed.
In @src/content/docs/developer-tools/sdks/native/react-native-sdk.mdx around
lines 186 - 202, The bridging header guidance is incomplete: ensure
AppDelegate+RNAppAuth.h (or your existing Objective-C Bridging Header) also
imports RCTLinkingManager so Swift can call RCTLinkingManager methods used by
RNAppAuth; add #import <React/RCTLinkingManager.h> alongside the existing
RNAppAuthAuthorizationFlowManager import, and update Step 2 to instruct
developers to add these imports to their existing bridging header instead of
replacing it if one already exists.
</details>
<!-- fingerprinting:phantom:poseidon:churro -->
<!-- This is an auto-generated reply by CodeRabbit -->
There was a problem hiding this comment.
Without exposing that header to Swift, the project won't compile
The project does compile.
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
React Native RCTLinkingManager Swift import bridging header
💡 Result:
To use RCTLinkingManager from Swift, you typically don’t import it in Swift directly—you expose the Objective‑C header to Swift via an Objective‑C bridging header, then call it from AppDelegate.swift.
1) Add RCTLinkingManager to your bridging header
Create (or edit) ios/<YourApp>/<YourApp>-Bridging-Header.h and add:
`#import` <React/RCTLinkingManager.h>This is a common React Native Swift bridging-header pattern and explicitly includes RCTLinkingManager for Swift visibility. [1]
Also make sure Xcode is pointing at the file:
Build Settings → Swift Compiler - General → Objective-C Bridging Header (set the relative path). [2]
2) Forward deep links in AppDelegate.swift
In your AppDelegate.swift, forward URL opens to React Native:
override func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
return RCTLinkingManager.application(app, open: url, options: options)
}This is the standard Swift equivalent of the Objective‑C openURL forwarding. [3]
Universal Links (optional)
override func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: `@escaping` ([UIUserActivityRestoring]?) -> Void
) -> Bool {
return RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
}[4]
Notes / common gotchas
- If you’re integrating other SDKs that also handle
openURL, you must combine the handlers into oneopenURLmethod (iOS only allows one). [5]
Sources: [1] [2] [3] [4] [5]
🌐 Web query:
React Native 0.70 RCTLinkingManager Swift automatic import module map
💡 Result:
To use RCTLinkingManager from Swift in a React Native 0.70 iOS app, you have two workable paths:
Option A (most common): Use a Bridging Header (no Swift import React needed)
-
Create/ensure you have an Objective‑C bridging header (e.g.
YourApp-Bridging-Header.h). -
Add:
`#import` <React/RCTLinkingManager.h>
(RN’s Swift/native-module docs call out that Swift↔ObjC interop requires a bridging header that imports the React headers you need.) [1]
-
In
AppDelegate.swift, callRCTLinkingManagernormally (noimport Reactrequired).
A common gotcha: make sure the #import <React/RCTLinkingManager.h> is actually compiled via the bridging header / correct target settings; otherwise Xcode will complain it can’t find the header. [2]
Option B: Enable an auto-generated module map so Swift can import React
If your goal is specifically “Swift automatic import” (i.e. import React), you need the React pods to define modules (generate module maps). CocoaPods’ standard fix is to enable modular headers:
- In your
ios/Podfileadd one of:use_modular_headers!(global), or:modular_headers => truefor specific pods
This is the documented CocoaPods approach when Swift pods (or Swift code) need module maps for dependencies that “do not define modules.” [3]
Then run:
cd ios
rm -rf Pods Podfile.lock
pod installWhich should you pick?
- If you only need
RCTLinkingManagerin the app delegate, Option A is usually simplest. - If you want to freely
import Reactin Swift across the app (and avoid bridging-header imports), use Option B.
Sources: React Native Swift/bridging-header guidance [1], RCTLinkingManager header import workaround [2], CocoaPods modular-headers/module-map requirement explanation [3].
@victoreronmosele, thank you for the clarification! I stand corrected. If the project compiles successfully without explicitly importing RCTLinkingManager in the bridging header, then my concern was unfounded.
It's possible that React Native's build configuration or module maps are making RCTLinkingManager available to Swift through other mechanisms (such as modular headers via CocoaPods). Since you've tested this and confirmed it works, the documentation as written should be fine.
I appreciate you taking the time to verify and correct my review comment!
🧠 Learnings used
Learnt from: victoreronmosele
Repo: kinde-oss/documentation PR: 639
File: src/content/docs/developer-tools/sdks/native/flutter-sdk.mdx:178-226
Timestamp: 2025-12-12T01:58:25.587Z
Learning: In Flutter SDK documentation using flutter_appauth, the `net.openid.appauth.RedirectUriReceiverActivity` is automatically handled by the plugin when the `appAuthRedirectScheme` manifest placeholder is set in `build.gradle`. Only `net.openid.appauth.AuthorizationManagementActivity` needs to be explicitly added to `AndroidManifest.xml` to configure its `taskAffinity` attribute for apps with `minSdkVersion < 30`.
Description (required)
This PR updates the deep link setup instructions to the SDK's latest version requirements.
Summary by CodeRabbit