当我从旧的三星或许多其他MeiZu设备访问指纹时出现问题,因此有任何api或其他东西使我可以在旧设备中访问指纹扫描仪吗? 世博会是否支持对Samsung和MeiZu api进行指纹扫描?或以其他方式在我的应用程序中包含此api? 谢谢。
有如下代码段
class AndroidScanner extends Component {
/**
* For showing scanner initially.
* @param props
*/
constructor(props) {
super(props);
this.state = {
showScanner: true,
};
}
/**
* For toggeling scanner.
* @private
*/
_toggleScanner() {
this.setState({showScanner: false});
}
componentDidMount() {
Expo.Fingerprint.hasHardwareAsync().then(response => {
hardware = response;
});
Expo.Fingerprint.isEnrolledAsync().then(response => {
enrolled = response;
});
}
authFunction = () => {
if (!hardware || !enrolled) {
let message = !hardware ? 'This device doesn\'t support fingerprint scanning.' : !enrolled ? 'No fingerprints registered.' : 'App has no permission.'
Toast.show(message, Toast.SHORT);
return;
}
if (this.state.showScanner === true) {
this._toggleScanner();
try {
Expo.Fingerprint.authenticateAsync().then(response => {
if (response.success) {
Toast.show("Auth successful!", Toast.SHORT);
this.props.onPreferences(userPreferences);
this.props.onLogin(decryptText(getAuthKey));
}
else if (response.error === 'app_cancel') {
return null;
} else {
this._toggleScanner();
Toast.show("Authentication Failure. Please Try Again!", Toast.SHORT);
Alert.alert("Authentication Failure", "Please authenticate to login.", [{
text: 'Ok',
onPress: () => {
this.props._toggleAndroidScanner()
}
}], {cancelable: false});
}
});
} catch (error) {
//if Finger scan will fail.
}
}
};
render() {
{
setTimeout(this.authFunction, 1000)
}
return (
<View>
<View style={androidScannerStyles.outerView}>
<Image source={require('../../assets/finger_print.png')}/>
<Text style={androidScannerStyles.fingerPrintStyle}>Place Your Finger</Text>
</View>
</View>
);
}
}