Xamarin example iOS

Hi I’m testing the xamarin skd, so far so good, it works great, the app always found the beacons, but I have a few questions, this is the code, I’m using

                    Config.SetupAppID ("", "");
		beaconManager = new BeaconManager ();
		beaconManager.RequestAlwaysAuthorization();
		beaconManager.ReturnAllRangedBeaconsAtOnce = true;
		var uuid = new NSUuid ("B9407F30-F5F8-466E-AFF9-25556B57FE6D");
		region = new BeaconRegion (uuid, "BeaconSample");
		region.NotifyOnEntry = true;
		beaconManager.StartRangingBeacons(region);
		//beaconManager.RangedBeacons += BeaconFound;
		beaconManager.EnteredRegion += EnteredRegion;

if I use the beaconManager.RangedBeacons event, the event triggers every 2 or 3 seconds when the phone is near the beacon, well its working but i guess this is not the correct event to trigger a local notification right?

I tried to use beaconManager.EnteredRegion event, but in this case nothing happened, the event does not rise. I don’t know if I’m missing something in my code.

my goal is to trigger a local notification, every time i’m 5 meters away from the beacon, if any one here can publish a sample code it will be great.

For EnteredRegion to work, you need to start monitoring instead of ranging. Learn more about the differences here: What are region Monitoring and Ranging?

Note that with default settings of beacon broadcasting power, the enter event will get triggered around 12-15 meters away from the beacon. If you want to make it 5 meters, you’ll need to readjust the beacon’s broadcasting power via the Estimote iOS app.

When you download the component it is full of examples. Checkout the NotificationViewController with this code:

beaconManager = new BeaconManager ();
			beaconRegion = new BeaconRegion (Beacon.ProximityUUID, Beacon.Major, Beacon.Minor, "BeaconSample");

			beaconRegion.NotifyOnEntry = enterSwitch.On;
			beaconRegion.NotifyOnExit = exitSwitch.On;

			enterSwitch.ValueChanged += HandleValueChanged;
			exitSwitch.ValueChanged += HandleValueChanged;

			beaconManager.StartMonitoring (beaconRegion);


			beaconManager.ExitedRegion += (sender, e) => 
			{
				var notification = new UILocalNotification();
				notification.AlertBody = "Exit region notification";
				UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
			};

			beaconManager.EnteredRegion += (sender, e) => 
			{
				var notification = new UILocalNotification();
				notification.AlertBody = "Enter region notification";
				UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
			};
1 Like

Thanks guys I’ll change my code and let you know the results