我正在进入Estimote Beacon应用程序开发,并能够使用示例应用程序发送通知,其中UUID,Major和Minor值在代码中显式硬编码。我希望使用Objective C实现以下要求。
我能够使用以下代码发送带有硬编码UUID,次要和主要值的通知。
对我有用的代码如下:
self.beaconNotificationsManager = [BeaconNotificationsManager new];
[self.beaconNotificationsManager enableNotificationsForBeaconID: [[BeaconID alloc] initWithUUIDString:@"MY UUID" major: 10708 minor:33584] enterMessage:@"Enter Message." exitMessage:@"Exit Message"];
谢谢, SIB移动开发人员
答案 0 :(得分:1)
您可以使用范围信标来实现发送“输入”和“退出”通知以及后台服务呼叫。
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"YOURUUID"];
self.beaconManager = [[ESTBeaconManager alloc] init];
self.beaconManager.delegate = self;
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"RegionIdenifier"];
self.beaconRegion.notifyOnEntry = YES;
self.beaconRegion.notifyOnExit = YES;
self.beaconRegion.notifyEntryStateOnDisplay = YES;
然后在委托方法中发送通知:
-(void)beaconManager:(ESTBeaconManager *)manager didEnterRegion:(CLBeaconRegion *)region
{
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = @"Enter region notification";
notification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
}
-(void)beaconManager:(ESTBeaconManager *)manager didExitRegion:(CLBeaconRegion *)region
{
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = @"Exit region notification";
notification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
}