Open mabn123 opened 5 years ago
this should give you a hint
connect (device) {
this.setState({ connecting: true })
BluetoothSerial.connect(device.id)
.then((res) => {
console.log(Connected to device ${device.name}
)
this.setState({ device, connected: true, connecting: false })
//////add this line to the connect function
this.props.navigation.navigate('Second',{device:device});
})
.catch((err) => console.log(err.message))
}
Thank you very much for the hint, however, my case requires me to utilize the BluetoothSerial.discoverUnpairedDevices() to scan for available unpaired devices and when a determined bluetooth id say
This is what I have come out so far but the activity never triggered despite the fact that the bluetooth signal exist: ` discoverUnpaired () {
const { unpairedDevices } = this.state ;
if (this.state.discovering) {
return false
}
else {
this.setState({ discovering: true })
BluetoothSerial.discoverUnpairedDevices()
.then((unpairedDevices) => {
this.setState({ unpairedDevices, discovering: false })
})
.catch((err) => Toast.showShortBottom(err.message))
unpairedDevices.filter(function(device){
return device.id == this.state.DEVICE_ID;
}).map(function(device,i){
if (device.id === this.state.DEVICE_ID){
this.props.navigation.navigate('Second');
}
});
}
}
`
The 'this.state.DEVICE_ID' is where the target device's device id is kept
Is it possible to trigger a navigation to a different activity/screen after detecting a specified bluetooth id? and how? I have been trying to make it happen but weren't successful