Estimote / iOS-Fleet-Management-SDK

Estimote Fleet Management SDK for iOS
https://developer.estimote.com
MIT License
1.18k stars 398 forks source link

didExitRegion and didEnterRegion not being called #155

Closed toptierlabs closed 10 years ago

toptierlabs commented 10 years ago

I don't know why didExitRegion and didEnterRegion aren't being called, my code is the following:

I've this in the didFinishLaunchingWithOptions of the AppDelagate

CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;

for (CLRegion *r in locationManager.monitoredRegions) {
    [locationManager stopMonitoringForRegion:r];
}

self.beaconManager = [[ESTBeaconManager alloc] init];
self.beaconManager.delegate = self;

NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"];

self.beaconRegion = [[ESTBeaconRegion alloc] initWithProximityUUID:uuid
                                                        identifier:@"MyApp"];
self.beaconRegion.notifyOnEntry = YES;
self.beaconRegion.notifyOnExit = YES;
self.beaconRegion.notifyEntryStateOnDisplay = YES;

[self.beaconManager startMonitoringForRegion:self.beaconRegion];

Also i have this two methods:

I add this delegate to the AppDelegate: ESTBeaconManagerDelegate

and this:

@property (nonatomic, strong) ESTBeaconManager beaconManager; @property (nonatomic, strong) ESTBeaconRegion beaconRegion;

I tried with this but didn't fix it:

CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;

for (CLRegion *r in locationManager.monitoredRegions) {
    [locationManager stopMonitoringForRegion:r];
}

Thanks!!

greggS commented 10 years ago

Hi! Please make sure first you have Background App Refresh enable on your iPhone. Also, if you are buiding the app using iOS8 SDK, you have to call "requestAlwaysAuthorization" on beaconManager.

toptierlabs commented 10 years ago

Hi! I had enable the Background App Refresh but I didn't call "requestAlwaysAuthorization". I have tried calling the "requestAlwaysAuthorization" but this didn't fix my problem:

self.beaconManager = [[ESTBeaconManager alloc] init];
self.beaconManager.delegate = self;

[self.beaconManager requestAlwaysAuthorization];

NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"];

self.beaconRegion = [[ESTBeaconRegion alloc] initWithProximityUUID:uuid
                                                        identifier:@"MyApp"];

self.beaconRegion.notifyOnEntry = YES;
self.beaconRegion.notifyOnExit = YES;
self.beaconRegion.notifyEntryStateOnDisplay = YES;

[self.beaconManager startMonitoringForRegion:self.beaconRegion];

Any idea? Thanks!!

toptierlabs commented 10 years ago

I could fix it, I had to add this to my .plist file:

NSLocationAlwaysUsageDescription This application monitors your location to show you promotional offers in shops you're passing by.

https://community.estimote.com/hc/en-us/articles/203393036-Estimote-SDK-and-iOS-8-Location-Services

Thanks!

smaspe commented 10 years ago

This is not very clear from the getting started documentation, and since that triggers no error, it can take some time to figure out.