Open ashmortar opened 6 years ago
This is how I personally go about it:
BluetoothCP.advertise();
// BluetoothCP.browse();
BluetoothCP.addPeerDetectedListener(function(user) {
if (typeof user !== 'undefined' && user !== null) {
BluetoothCP.inviteUser(user.id);
self.props.dispatch(SessionStateActions.addUser());
}
});
BluetoothCP.addPeerLostListener(function(user) {
self.setState({usersNumber: self.state.usersNumber - 1});
if (typeof user !== 'undefined' && user !== null) {
BluetoothCP.disconnectFromPeer(user.id);
self.props.dispatch(SessionStateActions.removeUser());
}
});
BluetoothCP.addInviteListener(function(user) {
if (typeof user !== 'undefined' && user !== null) {
BluetoothCP.acceptInvitation(user.id);
}
});
I have to check the user object because sometimes it would return an undefined
The action dispatched just logs the new discovered user somewhere in my app.
@virl I am also facing the same issue. I am using android 8 and only when wifi is turned on (But no internet) along bluetooth only then discovery works. It is not working only with bluetooth alone. Previously only bluetooth was working fine on android versions below 8.
Is there any specific handling to be done for devices above Android 7. Kindly clarify.
@vimalathiyagu Currently Bluetooth discovery and communication are not supported when both devices are Android 8+.
Thanks @virl
@virl will bluetooth be working again anytime soon?
hey @virl is there any update on 8+ versions issue?
I have set up a project in react-native and am trying to locate peers and advertise via bluetooth but when i getNearbyPeers the array returned is always empty. Are there any examples of how this is supposed to work?