Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/real-seas-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@callstack/react-native-brownfield': minor
---

feat: support linking in Expo and vanilla
19 changes: 19 additions & 0 deletions packages/react-native-brownfield/ios/ExpoHostRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@ final class ExpoHostRuntime {
) != nil
}

// Linking API; base implementation courtesy of Expo, licensed under the MIT License - changes were made to call the method on expo delegate - https://github.com/expo/expo/blob/main/apps/bare-expo/ios/AppDelegate.swift
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
return (expoDelegate?.application(app, open: url, options: options) ?? false) || RCTLinkingManager.application(app, open: url, options: options)
}

// Universal Links; base implementation courtesy of Expo, licensed under the MIT License - changes were made to call the method on expo delegate - https://github.com/expo/expo/blob/main/apps/bare-expo/ios/AppDelegate.swift
func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
return (expoDelegate?.application(application, continue: userActivity, restorationHandler: restorationHandler) ?? false) || result
}

func view(
moduleName: String,
initialProps: [AnyHashable: Any]?,
Expand Down
25 changes: 25 additions & 0 deletions packages/react-native-brownfield/ios/ReactNativeBrownfield.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,31 @@ internal import Expo
#endif
}

@objc public func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
#if canImport(Expo)
return ExpoHostRuntime.shared.application(app, open: url, options: options)
#else
return ReactNativeHostRuntime.shared.application(app, open: url, options: options)
#endif
}

// Universal Links
@objc public func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
#if canImport(Expo)
return ExpoHostRuntime.shared.application(application, continue: userActivity, restorationHandler: restorationHandler)
#else
return ReactNativeHostRuntime.shared.application(application, continue: userActivity, restorationHandler: restorationHandler)
#endif
}

/**
* Starts React Native with optional callback when bundle is loaded.
*
Expand Down
16 changes: 16 additions & 0 deletions packages/react-native-brownfield/ios/ReactNativeHostRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ final class ReactNativeHostRuntime {
return true
}

public func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
return RCTLinkingManager.application(app, open: url, options: options)
}

public func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
return RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
}

/**
* Starts React Native with optional callback when bundle is loaded.
*
Expand Down
Loading