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?