react-native-beacons-manager: iOS montioring when the app is killed/in background mode does not work
Version
1.0.7
Platform
iOS
OS version
iOS 11.0.2
Steps to reproduce
listener = DeviceEventEmitter.addListener(
'beaconsDidRange',
(data) => {
PushNotification.localNotificationSchedule({
message: 'Did Detect Beacon', // (required)
date: new Date(Date.now())
})
}
)
Beacons.requestAlwaysAuthorization()
Beacons.startMonitoringForRegion(region)
Beacons.startRangingBeaconsInRegion(region)
Beacons.startUpdatingLocation()
Expected behavior
Beacon should be detected also when the app is killed/in background mode
Actual behavior
The listener callback does not get called (it does get called on foreground)
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 28 (4 by maintainers)
We had the same problem.
Adding
self.locationManager.allowsBackgroundLocationUpdates = YES;
to the init method of RNIBeacon.m solved the problem.https://developer.apple.com/documentation/corelocation/cllocationmanager/1620568-allowsbackgroundlocationupdates
maybe some function like
would be helpful. This would allow the developer to control, when ranging in background really needed.
I just solve it by change the privacy. as your suggested, both “location always use” + “location when in use” description must fill something to make it works in the plist!
Hi All,
I enabled background update by setting BeaconsManager.allowsBackgroundLocationUpdates(true) in the beginning of componentWillMount
I would like to know if this suppose to work for only single region or multi region as I noticed when I am sending ranging information from multi region I will only get one region update instead of all of it. Or if I am doing something wrong so not all then not all region ranging update are send while in phone is locked.
Thank you 😄