diff --git a/ios/RCTShareExtensionHandlerModule.m b/ios/RCTShareExtensionHandlerModule.m index 3891cecf4c33..569e0da8b71a 100644 --- a/ios/RCTShareExtensionHandlerModule.m +++ b/ios/RCTShareExtensionHandlerModule.m @@ -11,6 +11,7 @@ NSString *const ShareExtensionGroupIdentifier = @"group.com.new-expensify"; NSString *const ShareExtensionFilesKey = @"ShareFiles"; +NSString *const ShareImageFileExtension = @".png"; @implementation RCTShareExtensionHandlerModule diff --git a/src/pages/share/ShareRootPage.tsx b/src/pages/share/ShareRootPage.tsx index 26da0df7f290..7463a0d83303 100644 --- a/src/pages/share/ShareRootPage.tsx +++ b/src/pages/share/ShareRootPage.tsx @@ -1,16 +1,33 @@ -import React, {useEffect} from 'react'; -import {View} from 'react-native'; +import React, {useEffect, useRef} from 'react'; +import type {AppStateStatus} from 'react-native'; +import {AppState, View} from 'react-native'; import Text from '@components/Text'; import ShareExtensionHandlerModule from '@src/modules/ShareExtensionHandlerModule'; // type ShareRootPageProps = {}; export default function ShareRootPage() { + const appState = useRef(AppState.currentState); + + const handleAppStateChange = (nextAppState: AppStateStatus) => { + if (appState.current.match(/inactive|background/) && nextAppState === 'active') { + ShareExtensionHandlerModule.processFiles((processedFiles) => { + // eslint-disable-next-line no-console + console.log('PROCESSED FILES ', processedFiles); + }); + } + + appState.current = nextAppState; + // eslint-disable-next-line no-console + console.log('AppState', appState.current); + }; + useEffect(() => { - ShareExtensionHandlerModule?.processFiles((processedFiles) => { - // eslint-disable-next-line no-console - console.warn('PROCESSED FILES ', processedFiles); - }); + const appStateSubscription = AppState.addEventListener('change', handleAppStateChange); + + return () => { + appStateSubscription.remove(); + }; }, []); return (