We are using Estimote Beacons and the beacons local notification works fine when app is in foreground or backgroud. But am not able to get the notifications when app is closed or not open in background…
I am trying with CLLocationManager class for ranging beacons and respective delegates like -(void)locationManager:(CLLocationManager *)manager didRangeBeacons:
(NSArray *)beacons inRegion:(CLBeaconRegion *)region and working all the notifications in that delegate method.
I had enabled requestAlwaysAuthorization for location manager…
I even tried with ESTBeaconManager and respectively with the samples available in the developer forum… but i am not getting the Notifications when app is closed or not open in background…
** I am manually removing the app from background (From multitasking panel - by double clicking the home button and removing the app)…
So, can you please guide me in how to get the local notifications when the app is not open.
and as soon as i enter beacon region, didenterregion delegate method is called…but in this delegate method i need to get the beacon details like uuid, major value and minor value… i need to use around 20-30 beacons and i am thinking to have same UUID for all the beacons and different major and minor values… So, in this delegate how can i get the details of the beacon as i need to get the information from the server based on these values…
I am trying to use rangingbeacons but as i read that this won’t show notifications when the app is not open. So as i read only monitoring beacons will show the notification when the app is not open… but if i start ranging beacons after monitoring beacons like as follows, then didenterregion is never called.
And may i know how often this monitoring beacons will be detecting beacons as for me once it detected a beacon and i had fliped the beacon to sleep and if i keep that beacon in position after a minute or two, then i get notification with few seconds delay…
So, may i know what would be idle to use like is it monitoring beacons or ranging beacons.
Can you please provide the code snippet to get the beacon details in didenterregion delegate method…
@heypiotr
I did this sample use beaconNotificationsManagerager but what i’m trying to do here is when > didEnterRegion get called generate localNotification , da same when didExitRegion so each beacon will have different text message and dynamic because msg saved on server in my case and fetch it each time my app open.
But didEnterRegion / didExitRegion never called when the app closed ??
i think the documentation messing something ? can u plz provide me with all tips and tricks i need to achieve what I want .
what I did for now
turn background mode for location update & uses Bluetooth & background fetch.
request always auth for location.
add text msg to info.plist file.
so let me know if I miss anything ?
Update:
AppIcon on lockScreen appear when my app close. “which mean that the phone can see the beacon” , but did start & end did not called :?
The BeaconNotificationsManager is just a higher-level wrapper on top of ESTBeaconManager, and it does exactly what you’re saying: in didEnterRegion and didExitRegion, generates and shows a UILocalNotification. It uses static messages, but you should be able to easily modify it to fetch msgs from a server.
turn background mode for location update & uses Bluetooth & background fetch.
You should not turn these on—you don’t need them to do background monitoring, only the “always” authorization. Having extraneous background modes enabled will get your app rejected during the review process.
Do you have your ESTBeaconManager and didEnter / Exit in the AppDelegate? Remember that if a app gets closed, all the View Controllers are deinitialized, and monitoring will stop working if you had the ESTBeaconManager in the View Controller. It’s described in greater detail in the above-mentioned tutorial.
That’s all good. Ranging only works when the app is running—either in the foreground, or in the background. And by default, when you leave the app, it transitions to the background for a few seconds (basically, iOS gives it time to save data) before being suspended, and that’s when ranging stops.
Then, if monitoring wakes the app and delivers the “enter” or “exit” event, it also run in the background for a few seconds (and ranging will work too), before it goes back to sleep (and ranging will stop working again).
I got it but I faced another problem here when “enter” and “exit” event it return CLBeaconRegion which have nullmajor&minor in my case because I thought it will return the beacon region not the region I start monitoring ??
what i’m trying to do , to solve this issue is start ranging when “enter” to get the beacon in range and send local notification depend on this beacon major&minor. but in my case sometimes there are 10 beacons at the same location which is really bad idea to follow this solution.
I found out that I can move to Eddystone implementation ? does that help ? or give me more option , or it will be the same ?
@heypiotr sorry for asking too many question and unrelated to the main question but I found out you are the only one who keep answer my questions
Ha, no worries man, I’m always happy to help. beacons! (That’s why I’m an evangelist I guess.)
So yeah, the thing with null major & minors is unfortunately a feature, not a bug. In iOS, if you startMonitoring for a region with just the UUID, then if enter happens, you won’t know which beacon exactly triggered the event.
One option is to monitor for UUID+major+minor, i.e., essentially for each individual beacon. If you define the region for monitoring this way, then in didEnter/didExit, you’ll have complete information. The downside: in iOS, you can only monitor for max 20 regions at a time.
Option #2 is the thing you already mentioned, i.e., do ranging when enter happens, and based on that try to figure out which beacon triggered the event. Like you noticed, it’s not always easy, as you might have a few beacons in range. But in most real-world use cases, this actually works really well: e.g., ranging tells you there are three beacons nearby, you take a look the their majors/minors, and you know that these are all entrance/lobby beacons, and thus decide to show a “hello” notification.
Eddystone at this time doesn’t have a “monitoring” option, only “scanning,” which is similar to iBeacon ranging.