Where are methods "didDetermineState:forRegion:and “requestStateForRegion:” for Notification class in Example App? I could not find them to leverage in Example App build on my phone.
Thank you for your support.
Where are methods "didDetermineState:forRegion:and “requestStateForRegion:” for Notification class in Example App? I could not find them to leverage in Example App build on my phone.
Thank you for your support.
Are you just looking for an example of how to use the method?
You can use something like this:
-(void)beaconManager:(ESTBeaconManager *)manager didDetermineState:(CLRegionState)state forRegion:(ESTBeaconRegion *)region
{
if (state == CLRegionStateInside) {
NSLog(@“Inside beacon region”);
}
}
But you can use it in a number of ways, switches etc…
Thanks @phillydev716. I was expecting it be available in Notification Demo. But this helps too.
Thanks again.
didDetermineState
will always be called alongside the didEnterRegion
and didExitRegion
if you’re doing monitoring, but you can also force it to get called via requestStateForRegion
.
The most common use for this delegate is to determine the initial state of the region, as enter and exit events are only getting called when the state changes. E.g. you launch your app, it starts monitoring, but at this point it doesn’t yet know if it’s already inside the geofence or not — so you can call the requestStateForRegion
and thus receive a call to didDetermineState
with “inside” or “outside” (or “unknown”, if the iOS can’t yet tell). And then when you leave/enter the range of beacons, it’ll receive enter/exit as usual.
Hope this makes sense, it’s all slightly convoluted (:
Thanks @heypiotr. I was having challenges with extracting the objects like" productImage "mentioned in “Notification Tutorial” for example app. I was expecting it to be available once I download the Example App. Am I missing something?
Ok. I was looking for “diddeterminstate” and “requestforstate” to assign an image to a beacon/region. The solution below does not use these methods but does assign an image and notification based on entry and exit to/from the region. Was able to get thru this , thanks to help from support, tutorial and Google.Here are the steps taken for other new comers to Beacon world:
1. Declare productImage as follows:
@property (nonatomic, strong) UIImageView* productImage;
2. Identify your regions based on beacons:
self.beaconRegion = [[ESTBeaconRegion alloc]
initWithProximityUUID:self.beacon.proximityUUID
major:xxxx
minor:yyyy
identifier:@"RegionIdentifier"
secured:self.beacon.isSecured];
self.beaconRegion1 = [[ESTBeaconRegion alloc]
initWithProximityUUID:self.beacon.proximityUUID
major:zzzz
minor:tutu
identifier:@"Region1Identifier"
secured:self.beacon.isSecured];
3. Define action based on region:
- (void)beaconManager:(ESTBeaconManager *)manager
didEnterRegion:(ESTBeaconRegion *)region
{
UILocalNotification *notification = [UILocalNotification new];
if (region.identifier == @"RegionIdentifier") {
notification.alertBody = @"Enter region notification";
} else if (region.identifier == @"Region1Identifier") {
notification.alertBody = @"Enter region1 notification";
}
}
4. Included the code in viewDidLoad
self.productImage = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self setProductImage];
[self.view addSubview:self.productImage];
5. Assign images to productImage
-(void)setProductImage
{
// product image when user is inside beacon zone
[self.productImage setImage:[UIImage imageNamed:@"immediate_image"]];
}
6. Call the image once in the region:
- (void)beaconManager:(ESTBeaconManager *)manager
didEnterRegion:(ESTBeaconRegion *)region
{
UILocalNotification *notification = [UILocalNotification new];
if([region.identifier isEqual:@"RegionIdentifier"])
{
notification.alertBody = @"Your message here";
[self setProductImage];
}
}
You can load as many images as you need in images_xcassets and use them for product image or discount image. (you can assign another image to DiscountImage just as it is done in ProductImage above)
I am sure there is an efficient way to do this but this should get you started.