Problems with monitoring a beacon on iOS

Hi there!

I have 2 questions regarding background monitoring of the beacons in the background on iOS. I have 3 beacons and I am able to track 2 of them in the foreground. The 3rd beacon, however, does not show any life on the app at all. I can track it from Estimote app and bluetooth scanners, but not from my own app. I use the same code for monitoring all of them.

AppDelegate.m

    #import "AppDelegate.h"
    #import <EstimoteSDK/EstimoteSDK.h>
    
    @interface AppDelegate () <ESTBeaconManagerDelegate>
    @property (nonatomic) ESTBeaconManager *beaconManager;
    @end

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   
    self.beaconManager = [ESTBeaconManager new];
    self.beaconManager.delegate = self;
  
    [self.beaconManager requestAlwaysAuthorization];
 
    [self.beaconManager startMonitoringForRegion:[[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc]
        initWithUUIDString:@"UUID String"] major: MAJOR_INT minor: MINOR_INT identifier:@"Area1"]];

    [self.beaconManager startMonitoringForRegion:[[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"UUID String"] major: MAJOR_INT minor: MINOR_INT identifier:@"Area2"]];
   //this beacon I am unable to monitor
    [self.beaconManager startMonitoringForRegion:[[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"UUID String"] major: MAJOR_INT minor: MINOR_INT identifier:@"Area3"]];
 
    return YES;
}

- (void)beaconManager:(id)manager didEnterRegion:(CLBeaconRegion *)region {
    
    if ([region.identifier isEqualToString:@"Area1"])
    {
        NSLog(@"entered Area1");
    }
    if ([region.identifier isEqualToString:@"Area2"])
    {
       NSLog(@"entered Area2");
    }
    if ([region.identifier isEqualToString:@"Area3"])
    {
       NSLog(@"entered Area3");
    }
   
}

- (void)beaconManager:(id)manager didExitRegion:(CLBeaconRegion *)region{
    
    if ([region.identifier isEqualToString:@"Area1"])
    {
        NSLog(@"left Area1");
    }
    if ([region.identifier isEqualToString:@"Area2"])
    {
      NSLog(@"left Area2");
    }
    if ([region.identifier isEqualToString:@"Area3"])
    {
        NSLog(@"left Area3");
    }
 
}

In the Info.plist I have:

<key>NSLocationAlwaysUsageDescription</key>
	<string>My message.</string>

The first question is: what could the reason that I am unable to track the beacon for Area3?

The second question is: monitoring for Area1 and Area2 works only in the foreground. Did I forget something?

Hi @andrii.matviienko!

After first look your code looks fine. As far as I understand all 3 beacons (including the one not working with your monitoring app) are broadcasting packets and you can see them in both Estimote App (Are you using radar/list view?) and BLE scanners (Are you looking for iBeacon or generic bluetooth device?). If you can see them we can exclude any device related issue (eg. flat battery, not broadcasting packets).

When we confirm that above is true, you should verify if Proximity UUID, Major and Minor values are properly set in all 3 devices. You can connect to them using Estimote App. To get enter/exit events for all 3 beacons each triplet of Proximity UUID, Major and Minor should be different. You can also implement beaconManager:monitoringDidFailForRegion:withError: to check if monitoring is not failing.

In terms of monitoring in background no additional work is required, your code should work out of the box as iOS is handling it. You can also try to use Notification template from Estimote Cloud (https://cloud.estimote.com/#/apps) as a reference.

Let me know if it helps and if you have any other questions!

I used radar tracking in Estimote App and in BLE scanners I was looking bluetooth devices with name “EST”. The beacon is present everywhere. UUIDs, majors/minors are also the different for all the beacons. As you suggested @Marcin_Klimek, I implemented beaconManager:monitoringDidFailForRegion:withError: in the following way:

 -(void)beaconManager:(id)manager monitoringDidFailForRegion:(CLBeaconRegion *)region withError:(NSError *)error
 {
     NSLog(@"Region: %@, error: %@", region.identifier, error.localizedDescription);
 }

but this method is never called.

Background monitoring for another 2 beacons worked. But monitoring for the 3rd is still strange.