Skip to content

Commit

Permalink
fix android/iOS compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
remicolin committed Aug 9, 2024
1 parent a412bfa commit 035e832
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions app/src/screens/MainScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,8 @@ import { mock_csca_sha256_rsa_4096, mock_dsc_sha256_rsa_4096 } from '../../../co
const { nativeModule } = NativeModules;
let emitter: NativeEventEmitter | null = null;

if (Platform.OS === 'android' && nativeModule) {
if (Platform.OS === 'android') {
emitter = new NativeEventEmitter(nativeModule);
} else if (Platform.OS === 'ios') {
// Use iOS-specific module or alternative implementation
// For example:
// emitter = new NativeEventEmitter(NativeModules.RNEventEmitter);
} else {
console.warn('Native module not found or not supported on this platform.');
}
import DatePicker from 'react-native-date-picker'
import StartScreen from './StartScreen';
Expand Down Expand Up @@ -219,14 +213,14 @@ const MainScreen: React.FC = () => {
setScanningMessage(event);
};

if (selectedTab === 'nfc' && emitter && Platform.OS === 'android') {
if (Platform.OS === 'android' && emitter) {
const subscription = emitter.addListener('NativeEvent', handleNativeEvent);

return () => {
subscription.remove();
};
}
}, [selectedTab]);
}, []);

useEffect(() => {
if (cscaProof && (modalProofStep === ModalProofSteps.MODAL_SERVER_SUCCESS)) {
Expand Down

0 comments on commit 035e832

Please sign in to comment.