Hello, I cant get any notifications. Neither in foreground nor in background mode. Im new to iOS and Objective-C. I've been googling around for last few days. Your demo app works but very slowly, you have to wait like 20-30 seconds to get a notification. But its still ok for my purposes. I tryed to edit the code but seems like nothing works. I would like to know how to make following things:
-App launches and opens browser, its a Web-App(done). And at the same time starts scanning for all beacons(Help needed by that).
-Once iBeacon or more iBeacons is found (and this should be done in foreground and also in background modes), app sends MySQL request to the server. Checks wether beacon/s UUID/s is in Database. If it is, app sends an AJAX request to the server, to load a HTML content in browser.** For now I would like just to send a LocalNotification to the user when a beacon is found.
No notifications for now needed if iPhone loses connection with beacon, only when finds, connects.
Sofar I've done this but I get no notifications at all, nothing happens, I can just see white background:
"ViewController.h" :
#import <UIKit/UIKit.h>
#import "ESTBeacon.h"
@interface ViewController : UIViewController
- (id)initWithBeacon:(ESTBeacon *)beacon;
@end
"ViewController.m" :
#import "ViewController.h"
#import "ESTBeaconManager.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;
}
return self;
}-
(void)viewDidLoad
{
[super viewDidLoad];self.beaconRegion = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTEPROXIMITYUUID
major:[self.beacon.major unsignedIntValue]
minor:[self.beacon.minor unsignedIntValue]
identifier:@"RegionIdentifier"];
self.beaconRegion.notifyEntryStateOnDisplay = YES;
self.beaconRegion.notifyOnEntry = YES;
self.beaconRegion.notifyOnExit = YES;[self configureReceiver];
}
-(void)configureReceiver
{
self.beaconManager = [[ESTBeaconManager alloc] init];
self.beaconManager.delegate = self;
[self.beaconManager startMonitoringForRegion:self.beaconRegion];
[self.beaconManager startRangingBeaconsInRegion:self.beaconRegion];
}
(void)beaconManager:(ESTBeaconManager *)manager didEnterRegion:(ESTBeaconRegion *)region
{
UILocalNotification *notification = [UILocalNotification new];
notification.alertBody = @"Enter region notification";
notification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
}(void)beaconManager:(ESTBeaconManager *)manager didExitRegion:(ESTBeaconRegion *)region
{
UILocalNotification *notification = [UILocalNotification new];
notification.alertBody = @"Exit region notification";
notification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
}
@end