Notification's wont work

Iv'e tried everything. They were working great entering and exiting a region then poof stopped working. The demo works great, my code works great for ranging but cannot get a local notification to pop up upon entering/exiting a region. Here is my whole .m file code. Please any help would be so appreciated.

//
// ViewController.m
// ESTTest
//
// Created by Michael Kane on 9/13/14.
// Copyright (c) 2014 Michael Kane. All rights reserved.
//

#import "ViewController.h"
#import <ESTBeaconManager.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import <CoreLocation/CoreLocation.h>

@interface ViewController () <ESTBeaconManagerDelegate>

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

@end

@implementation ViewController

-(id)initWithBeacon:(ESTBeacon *)beacon
{
self = [super init];
if (self)
{
self.beacon = beacon;
NSLog(@"Initiation got called");
}
return self;
}

  • (void)viewDidLoad {
    [super viewDidLoad];
    [self.beaconManager requestAlwaysAuthorization];

    if (self)
    {
    self.beacon = _beacon;
    NSLog(@"Initiation got called");
    }

    self.beaconManager = [[ESTBeaconManager alloc] init];
    self.beaconManager.delegate = self;
    self.beaconManager.avoidUnknownStateBeacons = YES;
    self.beaconRegion = [[ESTBeaconRegion alloc] initWithProximityUUID:self.beacon.proximityUUID
    major:[self.beacon.major unsignedIntegerValue]
    minor:[self.beacon.minor unsignedIntegerValue] identifier:@"RegionIdentifier"];

    self.beaconRegion.notifyOnEntry = YES;
    self.beaconRegion.notifyOnExit = YES;
    [self.beaconManager startMonitoringForRegion:self.beaconRegion];
    [self.beaconManager startRangingBeaconsInRegion:self.beaconRegion];

}

  • (void)beaconManager:(ESTBeaconManager *)manager didEnterRegion:(ESTBeaconRegion *)region
    {
    UILocalNotification *notification = [[UILocalNotification alloc]init];
    notification.alertBody = @"Enter region notification";
    NSLog(@"Entered the region");
    [[UIApplication sharedApplication] presentLocalNotificationNow:notification];
    }

  • (void)beaconManager:(ESTBeaconManager *)manager didExitRegion:(ESTBeaconRegion *)region
    {
    UILocalNotification *notification = [UILocalNotification new];
    notification.alertBody = @"Exit region notification";

    [[UIApplication sharedApplication] presentLocalNotificationNow:notification];
    }

-(void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(ESTBeaconRegion *)region
{
if (beacons.count > 0) {
ESTBeacon *firstBeacon = [beacons firstObject];
self.myLabel.text = [self textForProximity:firstBeacon.proximity];
}
}

-(NSString *)textForProximity:(CLProximity)proximity
{
switch (proximity) {
case CLProximityFar:
NSLog(@"far");
return @"Far";
break;
case CLProximityNear:
NSLog(@"near");
return @"Near";
break;
case CLProximityImmediate:
self.view.backgroundColor = [UIColor blueColor];
NSLog(@"immediate");
return @"Immediate";
break;
case CLProximityUnknown:
NSLog(@"unknown " );
return @"Unknown";
break;
default:
break;
}
}
@end

Hi Mike,

I don't see - if([launchOptions objectForKey:@"UIApplicationLaunchOptionsLocationKey"]) in your code. More about it here: https://community.estimote.com/hc/en-us/articles/203253193-Launching-notifications-in-iOS-when-the-app-is-killed

Best,

Hi Mike -- can you confirm that you have added NSLocationAlwaysUsageDescription to your Info.plist file?

Also, in iOS 8 you need to explicitly ask permission to show notifications. You can do that by adding the following lines to your AppDelegate:

if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
    [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}