Skip to content

Commit

Permalink
Fixes issue with the Example App crashing on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardocolombo committed Jul 29, 2021
1 parent beb0a34 commit bb3dbf3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
5 changes: 3 additions & 2 deletions example/RNExampleApp/src/Overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import React from 'react';
import { Button, Platform, StyleSheet, Text, View, ScrollView } from 'react-native';

export default function Overview({ openAnyline, checkCameraPermissionAndOpen, disabled }) {
export default function Overview({ updateAnyline, checkCameraPermissionAndOpen, disabled }) {

const platformPermissionCheck = (Platform.OS === 'android') ? checkCameraPermissionAndOpen : updateAnyline;

const platformPermissionCheck = (Platform.OS === 'android') ? checkCameraPermissionAndOpen : openAnyline;
const iOS = Platform.OS === 'ios';

return (
Expand Down
41 changes: 23 additions & 18 deletions example/RNExampleApp/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import ParallelScanningConfig from '../config/ParallelScanningConfig';
import TinConfig from '../config/TINConfig';
import OtaConfig from '../config/OtaConfig';
import { DeviceEventEmitter } from 'react-native';
import { Platform } from 'react-native';


// Disable Warnings
Expand Down Expand Up @@ -70,24 +71,28 @@ class Anyline extends Component {
}

updateAnyline = async type => {
let otaConfig = OtaConfig;

AnylineOCR.initSdk(otaConfig.license)
const onSessionConnect = (event) => {
console.log(event.progress);
};
DeviceEventEmitter.addListener('ota_progress_update_event', onSessionConnect);
AnylineOCR.update(
JSON.stringify(otaConfig),
(message) => {
console.log(`Error: ${message}`);
},
() => {
console.log(`DONE`);
this.openAnyline(type)
}
)
if(Platform.OS === 'android') {
let otaConfig = OtaConfig;

AnylineOCR.initSdk(otaConfig.license)
const onSessionConnect = (event) => {
console.log(event.progress);
};
DeviceEventEmitter.addListener('ota_progress_update_event', onSessionConnect);
AnylineOCR.update(
JSON.stringify(otaConfig),
(message) => {
console.log(`Error: ${message}`);
},
() => {
console.log(`DONE`);
this.openAnyline(type)
}
)
} else {
this.openAnyline(type);
}
};

openAnyline = async type => {
this.setState({buttonsDisabled: true});
Expand Down Expand Up @@ -380,4 +385,4 @@ const styles = StyleSheet.create({
},
});

export default Anyline;
export default Anyline;

0 comments on commit bb3dbf3

Please sign in to comment.