#import "AdvBar.h" #import "TQBeaconManager.h" @class AdvBar, TQBeaconManager; @interface tQBlogViewController : UIViewController { AdvBar *ab; }
TQBeaconManager *beaconManager = [TQBeaconManagersharedTQBeaconManager]; beaconManager.delegate = self; [beaconManager startMonitoringBeaconsForAppId:@"bef99647d04b44ec90c327a5ab599eec"];
-(void)userEnteredRegion: (NSString *)regionIdentifier; -(void)userExitedRegion: (NSString *)regionIdentifier; -(void)beaconFound:(CLBeacon *)beacon beaconProximity:(NSString *)proximity data:(NSDictionary *)extraData;
Add code inside respective delegate method in order to respond to user entering / exiting a region OR user's proximity to the beacon.(Code for any change in your app's view OR notification will go in the delegate method)
You can also invoke an ad view based on beacon proximity by adding below mentioned snippet in
-(void)beaconFound … method
NOTE:
Ideally, you should pass uuid, major and minor values of the closest beacon
// Invoking ad for the beacon -(void)beaconFound:(CLBeacon *)beacon beaconProximity:(NSString *)proximity data:(NSDictionary *)extraData { CLBeacon *foundBeacon = [beacons firstObject]; // You can retrieve the beacon data from its properties NSString *uuid = foundBeacon.proximityUUID.UUIDString; NSString *major = [NSStringstringWithFormat:@"%@", foundBeacon.major]; NSString *minor = [NSStringstringWithFormat:@"%@", foundBeacon.minor]; NSDictionary *dict = [[NSDictionaryalloc] initWithObjects:[NSArrayarrayWithObject:uuid,major,minor] forKeys:[NSArrayarrayWithObject:@"uuid",@"major",@"minor"]]; [[NSNotificationCenterdefaultCenter] postNotificationName:@"CustomTrigger"object:self.calledByuserInfo:dict]; }