-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: requestTechnology support multi-techs
- Loading branch information
1 parent
dcb26b8
commit 65e8f02
Showing
4 changed files
with
113 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react'; | ||
import { | ||
View, | ||
Text, | ||
Button, | ||
Platform, | ||
TouchableOpacity, | ||
Linking, | ||
TextInput, | ||
ScrollView, | ||
} from 'react-native'; | ||
import NfcManager, {NfcTech} from '../NfcManager'; | ||
|
||
class AppMultiTech extends React.Component { | ||
componentDidMount() { | ||
NfcManager.start(); | ||
} | ||
|
||
componentWillUnmount() { | ||
this._cleanUp(); | ||
} | ||
|
||
render() { | ||
return ( | ||
<View style={{padding: 20}}> | ||
<Text>NFC Multi-tech Demo</Text> | ||
<TouchableOpacity | ||
style={{padding: 10, width: 200, margin: 20, borderWidth: 1, borderColor: 'black'}} | ||
onPress={this._testMultiTech} | ||
> | ||
<Text>Test</Text> | ||
</TouchableOpacity> | ||
|
||
<TouchableOpacity | ||
style={{padding: 10, width: 200, margin: 20, borderWidth: 1, borderColor: 'black'}} | ||
onPress={this._cleanUp} | ||
> | ||
<Text>Cancel Test</Text> | ||
</TouchableOpacity> | ||
|
||
</View> | ||
) | ||
} | ||
|
||
_cleanUp = () => { | ||
NfcManager.cancelTechnologyRequest().catch(() => 0); | ||
NfcManager.unregisterTagEvent().catch(() => 0); | ||
} | ||
|
||
_testMultiTech = async () => { | ||
try { | ||
await NfcManager.registerTagEvent() | ||
let resp = await NfcManager.requestTechnology([NfcTech.IsoDep, NfcTech.Ndef]); | ||
console.warn(resp); | ||
let tag = await NfcManager.getTag(); | ||
console.warn(tag); | ||
this._cleanUp(); | ||
} catch (ex) { | ||
this._cleanUp(); | ||
} | ||
} | ||
} | ||
|
||
export default AppMultiTech; |