diff --git a/examples/react-native/android/app/src/main/AndroidManifest.xml b/examples/react-native/android/app/src/main/AndroidManifest.xml index a81aadef0a4..7645a6e2a4d 100644 --- a/examples/react-native/android/app/src/main/AndroidManifest.xml +++ b/examples/react-native/android/app/src/main/AndroidManifest.xml @@ -21,6 +21,12 @@ + + + + + + diff --git a/examples/react-native/ios/ReactNative.xcodeproj/project.pbxproj b/examples/react-native/ios/ReactNative.xcodeproj/project.pbxproj index 4f052d60929..da69e3c3ae8 100644 --- a/examples/react-native/ios/ReactNative.xcodeproj/project.pbxproj +++ b/examples/react-native/ios/ReactNative.xcodeproj/project.pbxproj @@ -576,6 +576,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\n\n$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\n\n$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\n\n$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\n\n$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\n\n"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, @@ -640,6 +641,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\n\n$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\n\n$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\n\n$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\n\n$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS\n\n"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, diff --git a/examples/react-native/ios/ReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/examples/react-native/ios/ReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000000..18d981003d6 --- /dev/null +++ b/examples/react-native/ios/ReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/examples/react-native/ios/ReactNative/AppDelegate.mm b/examples/react-native/ios/ReactNative/AppDelegate.mm index c13e671b8c4..b0944172217 100644 --- a/examples/react-native/ios/ReactNative/AppDelegate.mm +++ b/examples/react-native/ios/ReactNative/AppDelegate.mm @@ -3,6 +3,7 @@ #import #import #import +#import #import @@ -66,6 +67,21 @@ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge #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]; +} + #if RCT_NEW_ARCH_ENABLED #pragma mark - RCTCxxBridgeDelegate diff --git a/examples/react-native/ios/ReactNative/Info.plist b/examples/react-native/ios/ReactNative/Info.plist index dbd7000fa96..c3c5a4ff99e 100644 --- a/examples/react-native/ios/ReactNative/Info.plist +++ b/examples/react-native/ios/ReactNative/Info.plist @@ -1,55 +1,64 @@ - - CFBundleDevelopmentRegion - en - CFBundleDisplayName - ReactNative - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSRequiresIPhoneOS - - NSAppTransportSecurity - NSExceptionDomains + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ReactNative + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + NSAppTransportSecurity - localhost + NSExceptionDomains - NSExceptionAllowsInsecureHTTPLoads - + localhost + + NSExceptionAllowsInsecureHTTPLoads + + + NSLocationWhenInUseUsageDescription + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + CFBundleURLTypes + + + CFBundleURLSchemes + + myapp + + + - NSLocationWhenInUseUsageDescription - - UILaunchStoryboardName - LaunchScreen - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - - - + \ No newline at end of file diff --git a/examples/react-native/src/features/Authenticator/Demo/Demo.tsx b/examples/react-native/src/features/Authenticator/Demo/Demo.tsx index 600008b699f..579d3e3259f 100644 --- a/examples/react-native/src/features/Authenticator/Demo/Demo.tsx +++ b/examples/react-native/src/features/Authenticator/Demo/Demo.tsx @@ -1,6 +1,8 @@ import React from 'react'; import { StyleSheet, View } from 'react-native'; +import { useDeepLinkingDebug } from '../../../hooks'; + import { Authenticator, useAuthenticator } from '@aws-amplify/ui-react-native'; import { Amplify } from 'aws-amplify'; @@ -17,6 +19,8 @@ function SignOutButton() { } function App() { + useDeepLinkingDebug(); + return ( diff --git a/examples/react-native/src/hooks/index.ts b/examples/react-native/src/hooks/index.ts new file mode 100644 index 00000000000..66bdfba2dab --- /dev/null +++ b/examples/react-native/src/hooks/index.ts @@ -0,0 +1 @@ +export { default as useDeepLinkingDebug } from './useDeepLinkingDebug'; diff --git a/examples/react-native/src/hooks/useDeepLinkingDebug.ts b/examples/react-native/src/hooks/useDeepLinkingDebug.ts new file mode 100644 index 00000000000..17ee3287898 --- /dev/null +++ b/examples/react-native/src/hooks/useDeepLinkingDebug.ts @@ -0,0 +1,27 @@ +import { useEffect } from 'react'; +import { Linking } from 'react-native'; + +export const deepLinkHandler = ( + url: string | null | { url: string }, + shouldLog = true +) => { + if (!url) { + return; + } + + if (shouldLog) { + console.log('Detected url:', url); + } +}; + +export default async function useDeepLinking(shouldLog = true): Promise { + useEffect(() => { + Linking.addEventListener('url', deepLinkHandler); + }, []); + + try { + deepLinkHandler(await Linking.getInitialURL(), shouldLog); + } catch (e) { + console.log(`Cold boot deep link error: ${e}`); + } +}