Estimote Cloud notifications

In the Estimote CloudDemo app the enter and exit notifications are set as followed:

enterNotification.alertBody = item.cloudData.content.enterNote.text;
exitNotification.alertBody = item.cloudData.content.exitNote.text;

Looking at the code I assume the enter and exit notes are fetched from the cloud. Where can these notifications be editted? As far as I can tell I can only edit the views for each beacon in the estimote cloud.

Jurjen,

As for now you can't edit the notification itself. We're working on making this possible in the future.

Oke! And do I have to pass along the enterContent and exitContent in the userInfo of the local notification? The cloud demo app hints in this direction but I'm having difficulties getting this working. Or can this content be fetched from the cloud after opening the notification?

My current code:

NSMutableDictionary* eventDict = [NSMutableDictionary new];
[eventDict setObject:self.cloudItem.cloudData.content.exitContent forKey: NOTIFICATIONCONTENT];
[eventDict setObject:[NSNumber numberWithInt:self.cloudItem.cloudData.color] forKey: NOTIFICATION
COLOR];
UILocalNotification *exitNotification = [[UILocalNotification alloc] init];
exitNotification.userInfo = eventDict;

Results in:

Property list invalid for format: 200 (property lists cannot contain objects of type 'CFType')

If you want to display notifications, try using this code:

UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = self.cloudItem.cloudData.exitNote;
notification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];

Let me know, if that helped!

Displaying notifications isn't the problem. How can I present the Enter or Leaving Range view, which are defined in the Estimote Cloud, after opening the notification?

Are you using our Cloud demo app or creating your own?

I'm creating my own based on the Cloud demo app. I currently have the following code:

NSMutableDictionary* eventDict = [NSMutableDictionary new];
[eventDict setObject:self.cloudItem.cloudData.content.exitContent forKey: NOTIFICATIONCONTENT];
[eventDict setObject:[NSNumber numberWithInt:self.cloudItem.cloudData.color] forKey: NOTIFICATION
COLOR];

// present Local Push Notification
UILocalNotification *exitNotification = [[UILocalNotification alloc] init];
exitNotification.alertBody = self.cloudItem.cloudData.content.exitNote.text;
exitNotification.soundName = UILocalNotificationDefaultSoundName;
exitNotification.userInfo = eventDict; // this results in the error
[[UIApplication sharedApplication] presentLocalNotificationNow:exitNotification];

But this results in:

Property list invalid for format: 200 (property lists cannot contain objects of type 'CFType')

Hi Jurgen , where did you get the cloudDemoApp ? On ios sdk i only see proximity , distance and notification demo.
Thanks for your help.

Hi Maximilien,

Jurgen is asking about our demo app is currently under beta testing. Would you like to take part in the testing? If yes, please send me a direct e-mail.

Hi Ola or Ula,

Can you help me out with showing the enter or exit content after opening the notification?

Hi Jurjen,

It is not a problem with our SDK, but with what you try to include in Dictionary. Please read: http://stackoverflow.com/questions/4637179/uilocalnotification-crash

Especially this part:

Sounds like there are objects in your userInfo dictionary that don't implement the NSCoding protocol. Everything in that dictionary has to be able to be written to 'disk', since your app may not be running when the notification fires. If there's something in there that can't be serialized, this is the result.

Does it help?

Hi Ula,

I know it isn't a problem with your SDK. I'm just wondering how I can show the enter of exit cloud view after opening the associated local notification.

I now pass along the UUID of the beacon in the userInfo of the local notification. In the UIView which is shown after opening the notification I fetch all beacons from the cloud with ESTBeaconManager fetchEstimoteBeaconsWithContent. I then show the enterContent or exitContent of the beacon matching the UUID of the local notification.

Is there is a better way of implementing this? Can the enter or exitContent be passed along in the local notification for example?

Your approach is good.

Although answer to your original text has been changed. You can now edit the notification itself in the CMS/Cloud.

Can you share the code for starting monitoring? I'm interested in seeing region declaration and starting for monitoring.

Hi Wiktor,

I've noticed. Only issue I'm having now is that beaconManager didEnterRegion and didExitRegion is called multiple times for a single region, resulting in multiple UILocalNotifications. Somehow beaconManager stopMonitoringForRegion doesn't seem to work where as stopRangingBeaconsInRegion does work for the same region. I call both methods in my viewWillDisappear. Do you have any idea what could go wrong?

Here is my code:

NSString* regionID = [NSString stringWithFormat:@"Region%@:%@:%@",beacon.proximityUUID, beacon.major, beacon.minor ];
NSLog(@"Region: %@", regionID);
self.region = [[ESTBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:[beacon.proximityUUID UUIDString]]
major:[beacon.major unsignedShortValue]
minor:[beacon.minor unsignedShortValue]
identifier:regionID];

[self.beaconManager startRangingBeaconsInRegion:self.region];
[self.beaconManager startMonitoringForRegion:self.region];

And in my viewWillDisappear:

[self.beaconManager stopRangingBeaconsInRegion:self.region];
[self.beaconManager stopMonitoringForRegion:self.region];

Couple of notes:
1) didEnterRegion will not be triggered when you are inside the region, use requestStateForRegion in order to check if you are already inside/outside the region.

2) mixing ranging and monitoring in the same controller might not be best idea if you are controlling notification from both callbacks for monitoring and ranging

3) For each beacon you are constructing one region class. That means if 3 beacons are in range, you will have 3 distinct callback invocations for didEnterRegion.

I hope it will help.