void ConfigureView() { // Update the user interface for the detail item if (IsViewLoaded && detailItem != null) { detailDescriptionLabel.Text = detailItem.ToString(); } this.Title = detailItem.Code; if(peripheralMgr != null) { peripheralMgr.StopAdvertising(); } else { peripheralDelegate = new BTPeripheralDelegate(); peripheralMgr = new CBPeripheralManager(peripheralDelegate, DispatchQueue.DefaultGlobalQueue); } beaconUUID = new NSUuid(detailItem.UUID); beaconRegion = new CLBeaconRegion(beaconUUID, (ushort)detailItem.Major, (ushort)detailItem.Minor, beaconId); //power - the received signal strength indicator (RSSI) value (measured in decibels) of the beacon from one meter away var power = new NSNumber(-59); peripheralData = beaconRegion.GetPeripheralData(power); peripheralMgr.StartAdvertising(peripheralData); QRCode.LoadUrl(GenerateQRCodeUrl(detailItem.ToString(), QRCodeSize.Medium, QRErrorCorrection.H)); }
void ConfigureView() { // Update the user interface for the detail item if (IsViewLoaded && detailItem != null) { detailDescriptionLabel.Text = detailItem.ToString(); } this.Title = detailItem.Code; if (peripheralMgr != null) { peripheralMgr.StopAdvertising(); } else { peripheralDelegate = new BTPeripheralDelegate(); peripheralMgr = new CBPeripheralManager(peripheralDelegate, DispatchQueue.DefaultGlobalQueue); } beaconUUID = new NSUuid(detailItem.UUID); beaconRegion = new CLBeaconRegion(beaconUUID, (ushort)detailItem.Major, (ushort)detailItem.Minor, beaconId); //power - the received signal strength indicator (RSSI) value (measured in decibels) of the beacon from one meter away var power = new NSNumber(-59); peripheralData = beaconRegion.GetPeripheralData(power); peripheralMgr.StartAdvertising(peripheralData); QRCode.LoadUrl(GenerateQRCodeUrl(detailItem.ToString(), QRCodeSize.Medium, QRErrorCorrection.H)); }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear (animated); beaconUUID = new NSUuid (uuid); beaconRegion = new CLBeaconRegion (beaconUUID, beaconMajor, beaconMinor, beaconId); //power - the received signal strength indicator (RSSI) value (measured in decibels) of the beacon from one meter away var power = new NSNumber (-59); var peripheralData = beaconRegion.GetPeripheralData (power); peripheralDelegate = new BTPeripheralDelegate (); peripheralManager.StartAdvertising (peripheralData); }
public void Start(string UUID) { var proximityUUID = new NSUuid("12345678-1234-1234-1234-123456780001"); var beaconRegion = new CLBeaconRegion(proximityUUID, 100, 1, "Whatever"); //power - the received signal strength indicator (RSSI) value (measured in decibels) of the beacon from one meter away var power = new NSNumber(-59); NSMutableDictionary peripheralData = beaconRegion.GetPeripheralData(power); peripheralDelegate = new BTPeripheralDelegate(peripheralData); peripheralMgr = new CBPeripheralManager(peripheralDelegate, DispatchQueue.DefaultGlobalQueue); Console.WriteLine("Beacon Debug: " + "Started Advertising:" + UUID); ShowAlert("Started Advertising:" + UUID, 5); }
public override void ViewDidLoad () { base.ViewDidLoad (); beaconUUID = new NSUuid (uuid); beaconRegion = new CLBeaconRegion (beaconUUID, beaconMajor, beaconMinor, beaconId); //power - the received signal strength indicator (RSSI) value (measured in decibels) of the beacon from one meter away var power = new NSNumber (-59); NSMutableDictionary peripheralData = beaconRegion.GetPeripheralData (power); peripheralDelegate = new BTPeripheralDelegate (); peripheralMgr = new CBPeripheralManager (peripheralDelegate, DispatchQueue.DefaultGlobalQueue); peripheralMgr.StartAdvertising (peripheralData); }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); beaconUUID = new NSUuid(uuid); beaconRegion = new CLBeaconRegion(beaconUUID, beaconMajor, beaconMinor, beaconId); //power - the received signal strength indicator (RSSI) value (measured in decibels) of the beacon from one meter away var power = new NSNumber(-59); var peripheralData = beaconRegion.GetPeripheralData(power); peripheralDelegate = new BTPeripheralDelegate(); peripheralManager.StartAdvertising(peripheralData); }
public override void ViewDidLoad() { base.ViewDidLoad(); beaconUUID = new NSUuid(uuid); beaconRegion = new CLBeaconRegion(beaconUUID, beaconMajor, beaconMinor, beaconId); //power - the received signal strength indicator (RSSI) value (measured in decibels) of the beacon from one meter away var power = new NSNumber(-59); NSMutableDictionary peripheralData = beaconRegion.GetPeripheralData(power); peripheralDelegate = new BTPeripheralDelegate(); peripheralMgr = new CBPeripheralManager(peripheralDelegate, DispatchQueue.DefaultGlobalQueue); peripheralMgr.StartAdvertising(peripheralData); }
public override void ViewDidLoad() { base.ViewDidLoad (); var uuid = new NSUuid ("A1F30FF0-0A9F-4DE0-90DA-95F88164942E"); var beaconId = "iOSBeacon"; var beaconRegion = new CLBeaconRegion (uuid, beaconId) { NotifyEntryStateOnDisplay = true, NotifyOnEntry = true, NotifyOnExit = true }; var peripheralData = beaconRegion.GetPeripheralData (new NSNumber (-59)); peripheralDelegate = new BTPeripheralDelegate (); peripheralMgr = new CBPeripheralManager (peripheralDelegate, DispatchQueue.DefaultGlobalQueue); peripheralMgr.StartAdvertising (peripheralData); }
public override void ViewDidLoad() { base.ViewDidLoad(); var uuid = new NSUuid("A1F30FF0-0A9F-4DE0-90DA-95F88164942E"); var beaconId = "iOSBeacon"; var beaconRegion = new CLBeaconRegion(uuid, beaconId) { NotifyEntryStateOnDisplay = true, NotifyOnEntry = true, NotifyOnExit = true }; var peripheralData = beaconRegion.GetPeripheralData(new NSNumber(-59)); peripheralDelegate = new BTPeripheralDelegate(); peripheralMgr = new CBPeripheralManager(peripheralDelegate, DispatchQueue.DefaultGlobalQueue); peripheralMgr.StartAdvertising(peripheralData); }
public BeaconController() : base("BeaconController", null) { peripheralDelegate = new BTPeripheralDelegate(); peripheralManager = new CBPeripheralManager(peripheralDelegate, DispatchQueue.DefaultGlobalQueue); }
public FindTheMonkeyViewController() : base(UserInterfaceIdiomIsPhone ? "FindTheMonkeyViewController_iPhone" : "FindTheMonkeyViewController_iPad", null) { peripheralDelegate = new BTPeripheralDelegate (); peripheralMgr = new CBPeripheralManager (peripheralDelegate, DispatchQueue.DefaultGlobalQueue); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. var beaconRegion = new CLBeaconRegion(beaconId, beaconRegionName) { NotifyOnEntry = true, NotifyEntryStateOnDisplay = true, NotifyOnExit = true }; if (!UserInterfaceIdiomIsPhone) { //power - the received signal strength indicator (RSSI) value (measured in decibels) of the beacon from one meter away var power = new NSNumber(-59); NSMutableDictionary peripheralData = beaconRegion.GetPeripheralData(power); peripheralDelegate = new BTPeripheralDelegate(peripheralData); peripheralMgr = new CBPeripheralManager(peripheralDelegate, DispatchQueue.DefaultGlobalQueue); } else { locationMgr = new CLLocationManager(); locationMgr.RegionEntered += (object sender, CLRegionEventArgs e) => { if (e.Region.Identifier == beaconRegionName) { UILocalNotification notification = new UILocalNotification() { AlertBody = "Shark Warning! No Swimming!" }; UIApplication.SharedApplication.PresentLocationNotificationNow(notification); } }; locationMgr.RegionLeft += (object sender, CLRegionEventArgs e) => { if (e.Region.Identifier == beaconRegionName) { UILocalNotification notification = new UILocalNotification() { AlertBody = "Looks like it's safe to swim." }; UIApplication.SharedApplication.PresentLocationNotificationNow(notification); } }; CLProximity previousProximity = CLProximity.Unknown; locationMgr.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => { if (e.Beacons.Length > 0) { var beacon = e.Beacons[0]; if (beacon.Proximity == previousProximity) { return; } PlaySound(beacon.Proximity); beacon. switch (beacon.Proximity) { case CLProximity.Unknown: case CLProximity.Far: this.statusMessage.Text = "Is it true that most people get attacked by sharks in three feet of water about ten feet from the beach?"; this.View.BackgroundColor = UIColor.FromRGB(238, 214, 175); break; case CLProximity.Near: this.statusMessage.Text = "You're gonna need a bigger boat."; this.View.BackgroundColor = UIColor.FromRGB(206, 223, 239); break; case CLProximity.Immediate: this.statusMessage.Text = "It was nice to know ya."; this.View.BackgroundColor = UIColor.FromRGB(138, 7, 7); break; } previousProximity = beacon.Proximity; } }; locationMgr.StartMonitoring(beaconRegion); locationMgr.StartRangingBeacons(beaconRegion); } }
public FindTheMonkeyViewController() : base(UserInterfaceIdiomIsPhone ? "FindTheMonkeyViewController_iPhone" : "FindTheMonkeyViewController_iPad", null) { peripheralDelegate = new BTPeripheralDelegate(); peripheralMgr = new CBPeripheralManager(peripheralDelegate, DispatchQueue.DefaultGlobalQueue); }
public override void ViewDidLoad() { base.ViewDidLoad (); var monkeyUUID = new NSUuid (uuid); var beaconRegion = new CLBeaconRegion (monkeyUUID, monkeyId); beaconRegion.NotifyEntryStateOnDisplay = true; beaconRegion.NotifyOnEntry = true; beaconRegion.NotifyOnExit = true; if (!UserInterfaceIdiomIsPhone) { //power - the received signal strength indicator (RSSI) value (measured in decibels) of the beacon from one meter away var power = new NSNumber (-59); NSMutableDictionary peripheralData = beaconRegion.GetPeripheralData (power); peripheralDelegate = new BTPeripheralDelegate (); peripheralMgr = new CBPeripheralManager (peripheralDelegate, DispatchQueue.DefaultGlobalQueue); peripheralMgr.StartAdvertising (peripheralData); } else { InitPitchAndVolume (); locationMgr = new CLLocationManager (); locationMgr.RegionEntered += (object sender, CLRegionEventArgs e) => { if (e.Region.Identifier == monkeyId) { UILocalNotification notification = new UILocalNotification () { AlertBody = "There's a monkey hiding nearby!" }; UIApplication.SharedApplication.PresentLocationNotificationNow (notification); } }; locationMgr.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => { if (e.Beacons.Length > 0) { CLBeacon beacon = e.Beacons [0]; string message = ""; switch (beacon.Proximity) { case CLProximity.Immediate: message = "You found the monkey!"; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Green; break; case CLProximity.Near: message = "You're getting warmer"; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Yellow; break; case CLProximity.Far: message = "You're freezing cold"; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Blue; break; case CLProximity.Unknown: message = "I'm not sure how close you are to the monkey";; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Gray; break; } if(previousProximity != beacon.Proximity){ Speak (message); } previousProximity = beacon.Proximity; } }; locationMgr.StartMonitoring (beaconRegion); locationMgr.StartRangingBeacons (beaconRegion); } }
public override void ViewDidLoad() { base.ViewDidLoad(); if (!UserInterfaceIdiomIsPhone) { openMultipeerBrowser.TouchUpInside += (sender, e) => { StartMultipeerBrowser(); }; } else { StartMultipeerAdvertiser(); } var monkeyUUID = new NSUuid(uuid); var beaconRegion = new CLBeaconRegion(monkeyUUID, monkeyId); beaconRegion.NotifyEntryStateOnDisplay = true; beaconRegion.NotifyOnEntry = true; beaconRegion.NotifyOnExit = true; if (!UserInterfaceIdiomIsPhone) { //power - the received signal strength indicator (RSSI) value (measured in decibels) of the beacon from one meter away var power = new NSNumber(-59); NSMutableDictionary peripheralData = beaconRegion.GetPeripheralData(power); peripheralDelegate = new BTPeripheralDelegate(); peripheralMgr = new CBPeripheralManager(peripheralDelegate, DispatchQueue.DefaultGlobalQueue); peripheralMgr.StartAdvertising(peripheralData); } else { InitPitchAndVolume(); locationMgr = new CLLocationManager(); locationMgr.RegionEntered += (object sender, CLRegionEventArgs e) => { if (e.Region.Identifier == monkeyId) { UILocalNotification notification = new UILocalNotification() { AlertBody = "There's a monkey hiding nearby!" }; UIApplication.SharedApplication.PresentLocationNotificationNow(notification); } }; locationMgr.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => { if (e.Beacons.Length > 0) { CLBeacon beacon = e.Beacons [0]; string message = ""; switch (beacon.Proximity) { case CLProximity.Immediate: message = "You found the monkey!"; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Green; break; case CLProximity.Near: message = "You're getting warmer"; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Yellow; break; case CLProximity.Far: message = "You're freezing cold"; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Blue; break; case CLProximity.Unknown: message = "I'm not sure how close you are to the monkey"; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Gray; break; } if (previousProximity != beacon.Proximity) { Speak(message); // demo send message using multipeer connectivity if (beacon.Proximity == CLProximity.Immediate) { SendMessage(); } } previousProximity = beacon.Proximity; } }; locationMgr.StartMonitoring(beaconRegion); locationMgr.StartRangingBeacons(beaconRegion); } }
public BeaconController() : base("BeaconController", null) { peripheralDelegate = new BTPeripheralDelegate (); peripheralManager = new CBPeripheralManager (peripheralDelegate, DispatchQueue.DefaultGlobalQueue); }