I have this iBeacon application in swift that perform some task when didExitRegion and didEnterRegion are called. Everything works well except I am getting false alert in a way that I am within the beacon range and all the sudden didExitRegion is getting fired and immediately in a few secs later didEnterRegion getting fired again. This happens when either the phone or the beacon hasn't moved or anything blocked the signals.
I read somewhere that this is a bug on the Apple side. Not sure how true this is, but what's the work around this?
I was thinking to get the Alt, Lat every time the didExit is getting fired and compared with with the previous values or if there is a better way of doing this?
Thanks
I think a potential solution could be to move the code currently inside of your didExitRegion method into a new new method. In didExitRegion start a timer for 5 seconds (or whatever you find to work best) inside to call the new method when it fires.
Then, if didEnterRegion is called while the timer is running, cancel the timer and return from didEnterRegion.
From my experience, it seems this is something that happens when your device loses the beacon's signal momentarily while still within range. My apps have sent me didEnterRegion notifications every 5 minutes when I've been sitting right next to the beacon. From what I've read, the performance of the app depends on the quality of the beacon as far as signal strength and signal frequency.
This is a problem with beacons that do not transmit frequently enough. A didExitRegion event will fire on iOS if no beacon packets have been detected in 30 seconds. If a beacon is nearby and transmitting at the recommended 10 Hz, false positives are very, very rare.
Many beacon manufacturers reduce transmission rates to save battery, some making transmissions happen as seldom as every 5 seconds. This leads to bad performance and false exits. Not all beacon packets transmitted get received due to radio noise and interference. In practice, only 80-90% do. With a beacon transmitting every 5 seconds, 6 missed packets in a row will cause an exit event. This usually will not happen, but sometimes it will.
The best solution is to configure the beacon to transmit more often, ideally at 10 Hz or more. If you get a beacon that lets you do this and make it transmit that often, false exits will be very, very rare.
Related
I am implementing the IOS application with swift 3.0 which can monitor nearby beacons. I have an issue relating didRangeBeacon function, Detail reproduces steps below:
1- Application has entered beacon region
2- beacon is turned off
3- In next 10 seconds, didRangeBeacon function is still called and response still has one beacon object.
So I can not recognize beacon is off immediately. How can I recognize beacon is off immediately?
In case of iBeacon, the area is defined by the range of one or more beacons. This allows more granularity and precision than regular geofencing—the latter being based on a mix of signals from cell towers, WiFi and GPS. Beacon geofences are also more responsive: “enter” events usually take up to a few seconds to trigger, “exit” events up to 30 seconds. (Regular geofences take “3 to 5 minutes on average”, according to the CLLocationManager’s documentation.)
Testing “enter” events involves making sure you’re “outside” the region. Enabling “flip to sleep” makes it easy to simulate going out of range. “Enter” events take up to a few seconds to trigger, while “exit” events take up to 30 seconds.
Region monitoring is pretty slow, you can use it for more general notification to let you know. You can use this signal strength to decide if you no longer see the beacon (CoreLocation tends to still "see" the beacon a few seconds after it disapears).
I have an app where I'm scanning for beacons ( I know the UIIDs) and displaying them. The first few times I ran it I found the beacons almost immediately. But now each time I run it, it seems to take longer and longer to detect them. Even though I have the beacons sitting on the desk right next to the device.
I've tried replacing the batteries, changing from a iPhone to an iPad, checking a beacon scanning app on the Mac, rebuilding the app, etc. I also have a range of different beacons from different manufacturers and they all seem to have the same issue. Nothing seems to fix this.
My code basically looks like this:
let locationManager = CLLocationManager()
locationManager.delegate = self
let region = CLBeaconRegion(proximityUUID: UUID(uuidString:"61687109-905F-4436-91F8-E602F514C96D")!, identifier: "BlueCat beacon")
locationManager.startMonitoring(for: region)
And then I can wait for anything up to 5 or more minutes before any of the delegate methods get call.
This is the first time I've attempted to use beacons. Is this normal? Can it take a long time for a beacon to be seen by a device?
Under ideal conditions, didEnterRegion callbacks on iOS come within a few seconds of a beacon coming into range. Under less ideal conditions, these callbacks can take 15 minutes or more.
There are lots of things that can cause delays in detecting beacons when monitoring, and it's hard to say for sure without knowing exactly how you are testing. Two tips:
Hardware filter slots on iOS devices are limited and are on a first-come, first-served basis. If you have a bunch of beacon apps installed that have taken up these slots (or if your app has registered a bunch of regions), all these slots may have been taken up. Once hardware filter slots are gone, detections fall back to software scans that happen about every 15 minutes. Uninstall all apps (including yours) that may be holding on to these slots, then reinstall just your app.
Make sure you aren't "in region" when you put the app to the background. If iOS believes it is in the region, you won't get a new didEnterRegion callback until after it realizes it left the region and then entered again. The time for iOS to realize it exited the region is much longer than the time it takes to realize it entered. To ensure it realizes it exited the region, you should always range for beacons when the app is in the foreground, and leave the app ranging in the foreground for about a minute to ensure iOS realizes it is no longer in region (it usually takes 30 seconds of ranging to trigger an exit.) Only then should you put it in the background and turn on a beacon to measure detection times.
I'm working with a sample app for iBeacon region monitoring functionality. The Issue(not sure if it is) that I was unable to resolve is "didEnterRegion:" fires continuously for more than 2 times when I enter the region. This happens to send the local notification more than once or the times that this method fires when the app is in minimized mode.
Can anybody tell me how to resolve this.
Thanks,
It is common for a glitch in iOS to cause a didExitRegion event followed within a second by a didEnterRegion event. You can filter these out in your code by storing in an NSDate variable the time you last exited the region. When you get a didEnterRegion callback, you simply ignore it if the exit timestamp was within the last few secs.
If you are really getting these continuously as you say, something else is wrong that you may need to fix. It is possible that your iBeacon is not transmitting at least once every three seconds. This would cause constant exit/entry callbacks.
Take this scenario: user has an iPhone in the pocket passing by an iBeacon. Her phone is region monitoring for it. How much time is needed in real world to from entering the region to the moment app is woken up?
I have found an excellent article on the subject by David G. Young (http://developer.radiusnetworks.com/2013/11/13/ibeacon-monitoring-in-the-background-and-foreground.html) but I can't believe it can really take up to 15 minutes.
That would mean that all iBeacon home automation scenarios are simply unusable because you won't neither wait 15 mitutes in dark room for lights to switch on neither you would switch on the lights by actively using an app. Door opening and locking is another situation where iBeacon would be unusable (and NFC would work much better here). Or am I missing something?
I have an app that ranges for an iBeacons. It first grabs a list of couple proximityUUIDs and registers them as monitored regions.
When the device enters that region, it takes just 1 to several seconds (iPhone 5S) to post me a local notification on didEnterRegion: event.
When the app is in front, it starts ranging the beacon immediately in current region (if any) and updates happen in about one-second intervals.
When the app is in background, ranging is not enabled, otherwise it would immediately report that the beacon is gone (if you leave its range).
HOWEVER, It can really take up to 15 minutes (I've experienced this) for the device to post the didExitRegion: when in background in the worst case, when there is just significant location monitoring enabled combined with bad or no network. Otherwise it happens until about a minute.
Sorry, this didn't fit into a comment.
I'm having some major problems with iBeacons.
I can't figure out at all how I control the distance that triggers some sort of event (like the notification). I'm only allowed to send notification when i enter or exit region but i'd like to send notification when i'm near or immediate/
Where am I missing these things in the documentation ?
Thx !
The short answer is that you can't. Beacons enter the region as soon as the beacon is detected.
What you can do is to turn on both enter/exit notifications AND beacon ranging. Then in your app's handler for locationManager:didRangeBeacons:inRegion: you can either use the proximity property (far/near/immedate) or use the "Accuracy" reading (which is really a badly named approximate distance reading.)
You would ignore the ranging notices until you decide the user is close enough.
However, there's a big problem with this. If your app is in the background, you get a didEnterRegion notice, followed by about 5 seconds of ranging message. Then the ranging messages stop and your app goes back to sleep. After those 5 seconds you won't get any more notifications about that region until the user exits it.