App Generator Notification Demo

Hi guys, the app generator is pretty cool and the notification demo is working very good for one beacon.

The generated code looks like:

self.beaconNotificationsManager = [BeaconNotificationsManager new];
[self.beaconNotificationsManager enableNotificationsForBeaconID: [[BeaconID alloc] initWithUUIDString:@"B9..."
major:00000
minor:11111]
enterMessage:@"enter"
exitMessage:@"exit" ];

I changed the line with “enterMessage” and “exitMessage” to call a local function called (enter, exit)

enterMessage:self.enter
exitMessage:self.exit

The methods are pretty simple defined as:

-(NSString *)enter{
 NSLog(@"enter");
 }

-(NSString *)exit{
 NSLog(@"exit");
 }

When I start the App both methods are called. I realy need to call different methods on enter and exit calls. How can I do that?

Thanks

self.enter is a short-hand notation for [self enter], i.e., “call the method enter on the self object.” So what you’re really doing is, you’re calling the enter and exit methods immediately on app start, and passing their return values (in this case, nil, since you didn’t specify a return value—I actually think this gives a compilation warning) as the strings to use for the enter and exit messages.

If you want to execute custom code on enter/exit, then feel free to simple modify the didEnterRegion and didExitRegion methods in the BeaconNotificationsManager.

Thank you. I specified a return value as

NSString *foo = @"enter!";
return foo;

And there is no compilation warning.

Both methods are called immediately due to this line of code, right?

     [self.beaconNotificationsManager enableNotificationsForBeaconID: [[BeaconID alloc]
  initWithUUIDString:@"B9...."
 major:11111
 minor:0000] 
enterMessage:[self enter]
exitMessage:[self exit]
 ];

Can you explain how to modify the code to call custom didEnterRegion/didExitRegion methods?

Because I used your app generator there is not didEnterRegion Method. I tried to remove the enterMessage and exitMessage but I get a compilation error.

Thank you :smile:

Ok. I solved it. I didn’t know that the BeaconNotificationsManager.h and *.m files are available in the estimote folder. I implemented my custom methods directly in didEnterRegion in the Manager-file.

Thanks for helping me!
Florian

1 Like