From f7287c0b9c38884a674c52e95e89b40c4c376a66 Mon Sep 17 00:00:00 2001 From: alduzy Date: Thu, 7 Nov 2024 14:17:51 +0100 Subject: [PATCH] linking configured --- .../android/app/src/main/AndroidManifest.xml | 10 +- Example/ios/ScreensExample/AppDelegate.mm | 16 +++ Example/ios/ScreensExample/Info.plist | 100 ++++++++++-------- .../android/app/src/main/AndroidManifest.xml | 6 ++ .../ios/FabricExample/AppDelegate.mm | 16 +++ FabricExample/ios/FabricExample/Info.plist | 99 +++++++++-------- apps/Example.tsx | 29 ++++- 7 files changed, 178 insertions(+), 98 deletions(-) diff --git a/Example/android/app/src/main/AndroidManifest.xml b/Example/android/app/src/main/AndroidManifest.xml index b60a68d9bf..ffca916c86 100644 --- a/Example/android/app/src/main/AndroidManifest.xml +++ b/Example/android/app/src/main/AndroidManifest.xml @@ -20,8 +20,14 @@ android:windowSoftInputMode="adjustResize" android:exported="true"> - - + + + + + + + + diff --git a/Example/ios/ScreensExample/AppDelegate.mm b/Example/ios/ScreensExample/AppDelegate.mm index d033c8f07e..934d23ba2d 100644 --- a/Example/ios/ScreensExample/AppDelegate.mm +++ b/Example/ios/ScreensExample/AppDelegate.mm @@ -1,6 +1,7 @@ #import "AppDelegate.h" #import +#import @implementation AppDelegate @@ -28,4 +29,19 @@ - (NSURL *)bundleURL #endif } +- (BOOL)application:(UIApplication *)application + openURL:(NSURL *)url + options:(NSDictionary *)options +{ + return [RCTLinkingManager application:application openURL:url options:options]; +} + +- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity + restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler +{ + return [RCTLinkingManager application:application + continueUserActivity:userActivity + restorationHandler:restorationHandler]; +} + @end diff --git a/Example/ios/ScreensExample/Info.plist b/Example/ios/ScreensExample/Info.plist index 2eab1ca724..b22bc122c4 100644 --- a/Example/ios/ScreensExample/Info.plist +++ b/Example/ios/ScreensExample/Info.plist @@ -1,52 +1,60 @@ - - CFBundleDevelopmentRegion - en - CFBundleDisplayName - ScreensExample - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIRequiredDeviceCapabilities - - arm64 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - - NSLocationWhenInUseUsageDescription - - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - NSAllowsLocalNetworking + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ScreensExample + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + NSLocationWhenInUseUsageDescription + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSAllowsLocalNetworking + + + CFBundleURLTypes + + + CFBundleURLSchemes + + screensexample + + + - - + \ No newline at end of file diff --git a/FabricExample/android/app/src/main/AndroidManifest.xml b/FabricExample/android/app/src/main/AndroidManifest.xml index e1892528b8..6c541f944a 100644 --- a/FabricExample/android/app/src/main/AndroidManifest.xml +++ b/FabricExample/android/app/src/main/AndroidManifest.xml @@ -21,6 +21,12 @@ + + + + + + diff --git a/FabricExample/ios/FabricExample/AppDelegate.mm b/FabricExample/ios/FabricExample/AppDelegate.mm index 069118c92b..ff7a29b1c5 100644 --- a/FabricExample/ios/FabricExample/AppDelegate.mm +++ b/FabricExample/ios/FabricExample/AppDelegate.mm @@ -1,6 +1,7 @@ #import "AppDelegate.h" #import +#import @implementation AppDelegate @@ -28,4 +29,19 @@ - (NSURL *)bundleURL #endif } +- (BOOL)application:(UIApplication *)application + openURL:(NSURL *)url + options:(NSDictionary *)options +{ + return [RCTLinkingManager application:application openURL:url options:options]; +} + +- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity + restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler +{ + return [RCTLinkingManager application:application + continueUserActivity:userActivity + restorationHandler:restorationHandler]; +} + @end diff --git a/FabricExample/ios/FabricExample/Info.plist b/FabricExample/ios/FabricExample/Info.plist index 6701b8469a..eacf085192 100644 --- a/FabricExample/ios/FabricExample/Info.plist +++ b/FabricExample/ios/FabricExample/Info.plist @@ -1,51 +1,60 @@ - - CFBundleDevelopmentRegion - en - CFBundleDisplayName - FabricExample - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - $(MARKETING_VERSION) - CFBundleSignature - ???? - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - LSRequiresIPhoneOS - - NSAppTransportSecurity - NSAllowsArbitraryLoads - - NSAllowsLocalNetworking + CFBundleDevelopmentRegion + en + CFBundleDisplayName + FabricExample + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(MARKETING_VERSION) + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + LSRequiresIPhoneOS + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSAllowsLocalNetworking + + + NSLocationWhenInUseUsageDescription + + UILaunchStoryboardName + LaunchScreen.storyboard + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + CFBundleURLTypes + + + CFBundleURLSchemes + + screensfabricexample + + + - NSLocationWhenInUseUsageDescription - - UILaunchStoryboardName - LaunchScreen.storyboard - UIRequiredDeviceCapabilities - - arm64 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - - - + \ No newline at end of file diff --git a/apps/Example.tsx b/apps/Example.tsx index 49381ab308..54fb95e06a 100644 --- a/apps/Example.tsx +++ b/apps/Example.tsx @@ -123,6 +123,22 @@ const SCREENS: Record< }, }; +const linking = { + prefixes: ['screensexample://', 'screensfabricexample://'], + config: { + screens: { + Main: 'main', + ...Object.entries(SCREENS).reduce>( + (acc, [key, value]) => { + acc[key] = value.title.toLowerCase().replace(/\s+/g, '-'); + return acc; + }, + {}, + ), + }, + }, +}; + const isPlatformReady = (name: keyof typeof SCREENS) => { if (Platform.isTV) { return !!SCREENS[name].isTVOSReady; @@ -138,8 +154,8 @@ const playgrounds = screens.filter(name => SCREENS[name].type === 'playground'); type RootStackParamList = { Main: undefined; } & { - [P in keyof typeof SCREENS]: undefined; - }; + [P in keyof typeof SCREENS]: undefined; +}; const Stack = createNativeStackNavigator(); @@ -208,14 +224,17 @@ const ExampleApp = (): React.JSX.Element => { - +