Android Search Printer result will disappear on version 4.0.6-beta
I am try the search function on android by the syntax below
const { start, printerError, isDiscovering, printers } = usePrintersDiscovery()
Display
<View style={{flexDirection:'row',alignItems:'center',width:'100%'}} >
<Text style={}>Show android result</Text>
<FlatList
showsVerticalScrollIndicator={false}
showsHorizontalScrollIndicator={false}
data={printers}
keyExtractor={(item, index) => `${index}`}
renderItem={_renderPrinter_test}
horizontal={true}
// ListEmptyComponent={renderEmptyZoneHint}
/>
</View>
Trigger:
function doSearchPrinterAction() { start()
} printers will suddenly show up and disappear. every thing works on IOS. can you please
I found that on function PrintersDiscovery.onDiscovery
Android version didn't append the found printer list.
Hello
@powershek what is logs for "printers" array?
const { start, printerError, isDiscovering, printers } = usePrintersDiscovery()
console.log(printers) // here ??
Hello
@powershek what is logs for "printers" array?
const { start, printerError, isDiscovering, printers } = usePrintersDiscovery() console.log(printers) // here ??
I have found that it takes only one element. Bleutooth or WLAN , the last one remain . But in iOS, both listed in array
@aargon007 please try to increase timeout or disable auth stop
start({ timeout: 20000 })
or
start({ autoStop: false }) // don't forget to stop manually
PrintersDiscovery.onDiscovery ->. The android behaviour only return 1 printer each time, but IOS append in a list. I had change the code myself in usePrintersDiscovery.ts like this to work
var printerListAndroid = new Array();
useEffect(() => { const removeListener = PrintersDiscovery.onDiscovery( (deviceInfo: DeviceInfo[]) => { // console.log("printer deviceInfo=", deviceInfo, Platform.OS)
if (Platform.OS === 'ios') {
setPrinters(deviceInfo);
} else {
//setPrinters([...printers, ...deviceInfo]);
// console.log("printer android deviceInfo=", printerListAndroid, Platform.OS)
printerListAndroid.push(deviceInfo[0]);
setPrinters(printerListAndroid);
}
}
);
return () => {
removeListener();
};
}, []);
@powershek Seems I found the issue
Just released 4.0.1 with the fix. Please check and let me know if issue still exists
Issue resolved in 4.1.3