Iam使用react-native-beacons-manager库本地发现ibeacon信标,但是当我添加两个const region1和const region2然后使用Beacons.startRangingBeaconsInRegion(region1)和Beacons.startRangingBeaconsInRegion(region2)时,它不会什么都归还。
我使用的代码是
componentWillMount() {
Beacons.requestWhenInUseAuthorization();
const region = {
identifier: '973d0a2cf8f07443acdc71fad3df043d',
uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D',
major: 1,
minor: 2
};
const region2 = {
identifier: '39120dc19aa1a49c16b48bc4a5ea300b',
uuid: '5627DB35-B8A3-4EDC-987C-462CCB3B034F',
major: 2,
minor: 1
}
// Range for beacons inside the region
Beacons.startRangingBeaconsInRegion(region);
Beacons.startRangingBeaconsInRegion(region2);
Beacons.startUpdatingLocation();
}
componentDidMount() {
// Ranging: Listen for beacon changes
this.beaconsDidRange = DeviceEventEmitter.addListener(
'beaconsDidRange',
(data) => {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(data.beacons)
});
}
);
const UniqueID = DeviceInfo.getUniqueID();
}
componentWillUnMount() {
this.beaconsDidRange = null;
}