private CBPeripheral RetrieveKnownPeripheral(NSUuid deviceUuid)
        {
            if (deviceUuid == null || !deviceUuid.AsString().Any()) return null;

            CBPeripheral[] peripheralList = _centralManager.RetrievePeripheralsWithIdentifiers(deviceUuid);
            return peripheralList[0];
        }
Example #2
0
        public static void CheckInit(Dictionary<string, string> info)
        {
            if (peripheralManager != null)
                return;

            _info = info;

            NSUuid id;
            int i = 0;
            foreach (KeyValuePair<string, string> kvp in _info) {
                try {
                    id = new NSUuid (kvp.Value); // beaconId);
                } catch (Exception err) {
                    Global.ShowNotification (Plugin.Toasts.ToastNotificationType.Error, "iBeacon", "iBeacons UUID is wrong!");
                    return;
                }
                beaconRegion.Add (new CLBeaconRegion (id, kvp.Key)); //regionName);
            }
            peripheralDelegate = new PeripheralManagerDelegate ();
            peripheralDelegate.StateUpdatedEvent += PeripheralDelegate_StateUpdatedEvent;

            peripheralManager = new CBPeripheralManager (peripheralDelegate, DispatchQueue.DefaultGlobalQueue, new NSDictionary ());
            //peripheralManager = new CBPeripheralManager (ICBPeripheralManagerDelegate, DispatchQueue.DefaultGlobalQueue, new NSDictionary());
            //peripheralManager.StateUpdated += HandleStateUpdated;
        }
		public override void ViewWillAppear (bool animated)
		{
			base.ViewWillAppear (animated);
			CLBeaconRegion region = (CLBeaconRegion)locationManger.MonitoredRegions.AnyObject;
			enabled = (region != null);
			if (enabled) {
				uuid = region.ProximityUuid;
				major = region.Major;
				minor = region.Minor;
				notifyOnEntry = region.NotifyOnEntry;
				notifyOnExit = region.NotifyOnExit;
				notifyOnDisplay = region.NotifyEntryStateOnDisplay;
			} else {
				uuid = Defaults.DefaultProximityUuid;
				major = minor = null;
				notifyOnEntry = true;
				notifyOnExit = true;
				notifyOnDisplay = false;
			}

			majorTextField.Text = major == null ? String.Empty : major.Int32Value.ToString ();
			minorTextField.Text = minor == null ? String.Empty : minor.Int32Value.ToString ();

			uuidTextField.Text = uuid.AsString ();
			enabledSwitch.On = enabled;
			notifyOnEntrySwitch.On = notifyOnEntry;
			notifyOnExitSwitch.On = notifyOnExit;
			notifyOnDisplaySwitch.On = notifyOnDisplay;
		}
Example #4
0
        public override void ViewDidLoad()
        {
            this.View.BackgroundColor = UIColor.LightGray;

            guid = new NSUuid ("c5cf54e0-6dd8-45e9-91a3-a8cda2f41120");
            bRegion = new CLBeaconRegion (guid, "beacon");

            bRegion.NotifyEntryStateOnDisplay = true;
            bRegion.NotifyOnEntry = true;
            bRegion.NotifyOnExit = true;

            base.ViewDidLoad ();

            segBeacon = new UISegmentedControl (new string[] { "Beacon", "Finder" });
            segBeacon.Frame = new RectangleF (20, 50, this.View.Bounds.Width - 40, 50);
            segBeacon.SelectedSegment = 0;

            button = new UIButton (UIButtonType.RoundedRect);
            button.SetTitle ("Start!", UIControlState.Normal);
            button.Frame = new RectangleF (50, 150, this.View.Bounds.Width - 100, 30);

            button.TouchDown += HandleTouchDown;
            this.View.AddSubview (segBeacon);
            this.View.AddSubview (button);
        }
    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 MonitoringViewController (IntPtr handle) : base (handle)
		{
			locationManger = new CLLocationManager ();
			numberFormatter = new NSNumberFormatter () {
				NumberStyle = NSNumberFormatterStyle.Decimal
			};
			uuid = Defaults.DefaultProximityUuid;
		}
		void ScheduleURLSession ()
		{
			var uuuid = new NSUuid ();
			var backgroundConfigObject = NSUrlSessionConfiguration.CreateBackgroundSessionConfiguration (uuuid.AsString ());
			backgroundConfigObject.SessionSendsLaunchEvents = true;
			var backgroundSession = NSUrlSession.FromConfiguration (backgroundConfigObject);
			var downloadTask = backgroundSession.CreateDownloadTask (sampleDownloadURL);
			downloadTask.Resume ();
		}
		public ConfigurationViewController (IntPtr handle) : base (handle)
		{
			var peripheralDelegate = new PeripheralManagerDelegate ();
			peripheralManager = new CBPeripheralManager (peripheralDelegate, DispatchQueue.DefaultGlobalQueue);
			numberFormatter = new NSNumberFormatter () {
				NumberStyle = NSNumberFormatterStyle.Decimal
			};
			uuid = Defaults.DefaultProximityUuid;
			power = Defaults.DefaultPower;
		}
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			Near = UIImage.FromBundle ("Images/square_near");
			Far = UIImage.FromBundle ("Images/square_far");
			Immediate = UIImage.FromBundle ("Images/square_immediate");
			Unknown = UIImage.FromBundle ("Images/square_unknown");

			beaconUUID = new NSUuid (uuid);
			beaconRegion = new CLBeaconRegion (beaconUUID, beaconMajor, beaconId);


			beaconRegion.NotifyEntryStateOnDisplay = true;
			beaconRegion.NotifyOnEntry = true;
			beaconRegion.NotifyOnExit = true;

			locationmanager = new CLLocationManager ();

			locationmanager.RegionEntered += (object sender, CLRegionEventArgs e) => {
				if (e.Region.Identifier == beaconId) {

					var notification = new UILocalNotification () { AlertBody = "The Xamarin beacon is close by!" };
					UIApplication.SharedApplication.CancelAllLocalNotifications();
					UIApplication.SharedApplication.PresentLocationNotificationNow (notification);
				}
			};


			locationmanager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => {
				if (e.Beacons.Length > 0) {

					CLBeacon beacon = e.Beacons [0];
					//this.Title = beacon.Proximity.ToString() + " " +beacon.Major + "." + beacon.Minor;
				}
					
				dataSource.Beacons = e.Beacons;
				TableView.ReloadData();
			};







			locationmanager.StartMonitoring (beaconRegion);
			locationmanager.StartRangingBeacons (beaconRegion);



			TableView.Source = dataSource = new DataSource (this);
		}
Example #10
0
        public static void RegisterBeaconRegion(string uuid, ushort major, string regionId)
        {
            var NSUUID = new NSUuid (uuid);
            var beaconRegion = new CLBeaconRegion (NSUUID, major, regionId);

            beaconRegion.NotifyEntryStateOnDisplay = true;
            beaconRegion.NotifyOnEntry = true;
            beaconRegion.NotifyOnExit = true;

            locationManager.StartMonitoring (beaconRegion);
            locationManager.StartRangingBeacons (beaconRegion);

            beaconRegions.Add (beaconRegion);
        }
Example #11
0
		// create the CLBeaconRegion using the right contructor, returns null if input is invalid (no exceptions)
		public static CLBeaconRegion CreateRegion (NSUuid uuid, NSNumber major, NSNumber minor)
		{
			if (uuid == null)
				return null;
			if (minor == null) {
				if (major == null)
					return new CLBeaconRegion (uuid, Defaults.Identifier);
				else
					return new CLBeaconRegion (uuid, major.UInt16Value, Defaults.Identifier);
			} else if (major != null) {
				return new CLBeaconRegion (uuid, major.UInt16Value, minor.UInt16Value, Defaults.Identifier);
			}
			return null;
		}
        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);
		}
		partial void TakePhoto (NSObject sender)
		{
			var imagePicker = new UIImagePickerController ();
			var sourceType = UIImagePickerControllerSourceType.PhotoLibrary;

			if (UIImagePickerController.IsSourceTypeAvailable (UIImagePickerControllerSourceType.Camera))
				sourceType = UIImagePickerControllerSourceType.Camera;

			imagePicker.SourceType = sourceType;
			imagePicker.FinishedPickingMedia += async (picker, e) => {
				UIImage image = e.Info [UIImagePickerController.OriginalImage] as UIImage;
				var newSize = new SizeF (512, 512);

				if (image.Size.Width > image.Size.Height)
					newSize.Height = (int)(newSize.Width * image.Size.Height / image.Size.Width);
				else
					newSize.Width = (int)(newSize.Height * image.Size.Width / image.Size.Height);

				UIGraphics.BeginImageContext (newSize);
				image.Draw (new RectangleF (0, 0, newSize.Width, newSize.Height));
				var data = UIGraphics.GetImageFromCurrentImageContext ().AsJPEG (0.75f);
				UIGraphics.EndImageContext ();

				NSError error;
				var cachesDirectory = NSFileManager.DefaultManager.GetUrl (NSSearchPathDirectory.CachesDirectory, NSSearchPathDomain.User, null, true, out error);
				var temporaryName = new NSUuid ().AsString () + "jpeg";
				var localUrl = cachesDirectory.Append (temporaryName, false);
				data.Save (localUrl, true, out error);

				CKRecord record = await CloudManager.UploadAssetAsync (localUrl);
				if (record == null)
					return;

				assetRecordName = record.RecordId.RecordName;

				var alert = new UIAlertView ( "CloudKitAtlas", "Successfully Uploaded", null, "OK", null);
				alert.Show ();

				DismissViewController (true, null);
			};

			imagePicker.Canceled += (picker, e) => DismissViewController (true, null);

			PresentViewController (imagePicker, true, null);
		}
        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 async Task Connect(NSUuid peripheralUuid)
        {
            var peripheralHandler = _peripheralHandlerList.FirstOrDefault(p => p.Uuid.IsUuidEqual(peripheralUuid));
            if (peripheralHandler != null && peripheralHandler.IsConnected)
            {
                return;
            }

            using (var handler = new BluetoothConnectionHandler(_manager))
            {
                peripheralHandler = new PeripheralHandler(await handler.ConnectAsync(peripheralUuid));
                await peripheralHandler.InitializeAsync();

                peripheralHandler.InviteForDataExchange();
                _peripheralHandlerList.Add(peripheralHandler);

                OnConnectedUser(peripheralHandler);
            }
        }
        public Task<CBPeripheral> ConnectAsync(NSUuid peripheralUuid)
        {
            var currentPeripheral = RetrieveKnownPeripheral(peripheralUuid);

            if (currentPeripheral == null)
            {
                _connectedPeripheralTaskSource.TrySetException(
                    new Exception("Periphral device for selected user wasn't found"));
            }
            else if (currentPeripheral.State == CBPeripheralState.Connected)
            {
                _connectedPeripheralTaskSource.TrySetResult(currentPeripheral);
            }
            else
            {
                _centralManager.ConnectPeripheral(currentPeripheral);
            }

            return _connectedPeripheralTaskSource.Task;
        }
Example #18
0
		private void SetupBeaconRanging ()
		{
			locationManager = new CLLocationManager ();
			beacons = new List<BeaconItem> ();

			var rUuid = new NSUuid (roximityUuid);
			rBeaconRegion = new CLBeaconRegion (rUuid, roximityBeaconId);

			var eUuid = new NSUuid (estimoteUuid);
			eBeaconRegion = new CLBeaconRegion (eUuid, estimoteBeaconId);

			rBeaconRegion.NotifyEntryStateOnDisplay = true;
			rBeaconRegion.NotifyOnEntry = true;
			rBeaconRegion.NotifyOnExit = true;

			eBeaconRegion.NotifyEntryStateOnDisplay = true;
			eBeaconRegion.NotifyOnEntry = true;
			eBeaconRegion.NotifyOnExit = true;

			locationManager.RegionEntered += HandleRegionEntered;
			locationManager.RegionLeft += HandleRegionLeft;
			locationManager.DidDetermineState += HandleDidDetermineState;
			locationManager.DidRangeBeacons += HandleDidRangeBeacons;
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.Title = "Configure";

            enabledSwitch.ValueChanged += (sender, e) => {
                enabled = enabledSwitch.On;
            };

            uuidTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            uuidTextField.InputView        = new UuidPickerView(uuidTextField);
            uuidTextField.EditingDidBegin += HandleEditingDidBegin;
            uuidTextField.EditingDidEnd   += (sender, e) => {
                uuid = new NSUuid(uuidTextField.Text);
                NavigationItem.RightBarButtonItem = saveButton;
            };
            uuidTextField.Text = uuid.AsString();

            majorTextField.KeyboardType     = UIKeyboardType.NumberPad;
            majorTextField.ReturnKeyType    = UIReturnKeyType.Done;
            majorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            majorTextField.EditingDidBegin += HandleEditingDidBegin;
            majorTextField.EditingDidEnd   += (sender, e) => {
                major = numberFormatter.NumberFromString(majorTextField.Text);
                NavigationItem.RightBarButtonItem = saveButton;
            };

            minorTextField.KeyboardType     = UIKeyboardType.NumberPad;
            minorTextField.ReturnKeyType    = UIReturnKeyType.Done;
            minorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            minorTextField.EditingDidBegin += HandleEditingDidBegin;
            minorTextField.EditingDidEnd   += (sender, e) => {
                minor = numberFormatter.NumberFromString(minorTextField.Text);
                NavigationItem.RightBarButtonItem = saveButton;
            };

            measuredPowerTextField.KeyboardType     = UIKeyboardType.NumberPad;
            measuredPowerTextField.ReturnKeyType    = UIReturnKeyType.Done;
            measuredPowerTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            measuredPowerTextField.EditingDidBegin += HandleEditingDidBegin;
            measuredPowerTextField.EditingDidEnd   += (sender, e) => {
                power = numberFormatter.NumberFromString(measuredPowerTextField.Text);
                NavigationItem.RightBarButtonItem = saveButton;
            };

            doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (sender, e) => {
                uuidTextField.ResignFirstResponder();
                majorTextField.ResignFirstResponder();
                minorTextField.ResignFirstResponder();
                measuredPowerTextField.ResignFirstResponder();
                TableView.ReloadData();
            });

            saveButton = new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, e) => {
                if (peripheralManager.State < CBPeripheralManagerState.PoweredOn)
                {
                    new UIAlertView("Bluetooth must be enabled", "To configure your device as a beacon", null, "OK", null).Show();
                    return;
                }

                if (enabled)
                {
                    CLBeaconRegion region = Helpers.CreateRegion(uuid, major, minor);
                    var p = region.GetPeripheralData(power);
                    if (region != null)
                    {
                        peripheralManager.StartAdvertising(region.GetPeripheralData(power));
                    }
                }
                else
                {
                    peripheralManager.StopAdvertising();
                }

                NavigationController.PopViewController(true);
            });

            NavigationItem.RightBarButtonItem = saveButton;
        }
Example #20
0
 public static Guid ToGuid(this NSUuid uuid) => Guid.ParseExact(uuid.AsString(), "d");
Example #21
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var beaconUUID   = new NSUuid(uuid);
            var beaconRegion = new CLBeaconRegion(beaconUUID, beaconId);

            beaconRegion.NotifyEntryStateOnDisplay = true;
            beaconRegion.NotifyOnEntry             = true;
            beaconRegion.NotifyOnExit = true;

            locationManager = new CLLocationManager();

            locationManager.RequestWhenInUseAuthorization();

            locationManager.DidStartMonitoringForRegion += (object sender, CLRegionEventArgs e) => {
                locationManager.RequestState(e.Region);
            };

            locationManager.RegionEntered += (object sender, CLRegionEventArgs e) => {
                if (e.Region.Identifier == beaconId)
                {
                    Console.WriteLine("beacon region entered");
                }
            };

            locationManager.DidDetermineState += (object sender, CLRegionStateDeterminedEventArgs e) => {
                switch (e.State)
                {
                case CLRegionState.Inside:
                    Console.WriteLine("region state inside");
                    break;

                case CLRegionState.Outside:
                    Console.WriteLine("region state outside");
                    break;

                case CLRegionState.Unknown:
                default:
                    Console.WriteLine("region state unknown");
                    break;
                }
            };

            locationManager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => {
                if (e.Beacons.Length > 0)
                {
                    CLBeacon beacon = e.Beacons [0];

                    switch (beacon.Proximity)
                    {
                    case CLProximity.Immediate:
                        message = "Immediate";
                        break;

                    case CLProximity.Near:
                        message = "Near";
                        break;

                    case CLProximity.Far:
                        message = "Far";
                        break;

                    case CLProximity.Unknown:
                        message = "Unknown";
                        break;
                    }

                    if (previousProximity != beacon.Proximity)
                    {
                        Console.WriteLine(message);
                    }
                    previousProximity = beacon.Proximity;
                }
            };

            locationManager.StartMonitoring(beaconRegion);
            locationManager.StartRangingBeacons(beaconRegion);
        }
 public void DidDelete(INUIEditVoiceShortcutViewController controller, NSUuid deletedVoiceShortcutIdentifier)
 {
     refreshSubject.OnNext(Unit.Default);
     controller.DismissViewController(true, null);
 }
Example #23
0
 public static Guid ToGuid(this NSUuid uuid)
 {
     return(Guid.ParseExact(uuid.AsString(), "d"));
 }
Example #24
0
 public virtual void ReportNewIncomingCall(NSUuid uuid, CXCallUpdate update, Action <NSError> completion) => throw new PlatformNotSupportedException(Constants.UnavailableOnMacOS);
Example #25
0
 public static bool IsUuidEqual(this CBPeripheral peripheral, NSUuid uuid)
 {
     return peripheral.Identifier.AsString().Equals(uuid.AsString(), StringComparison.OrdinalIgnoreCase);
 }
 public static Guid ToShared(this NSUuid uuid)
 => Guid.Parse(uuid.Description);
Example #27
0
        public static Task ShowDialogTaskAsync(this IBandNotificationManager manager, NSUuid tileID, string title, string body)
        {
            var tcs = new TaskCompletionSource <object> ();

            manager.ShowDialogAsync(tileID, title, body, tcs.AttachCompletionHandler());
            return(tcs.Task);
        }
Example #28
0
        public static Task RegisterPushNotificationTaskAsync(this IBandNotificationManager manager, NSUuid tileID)
        {
            var tcs = new TaskCompletionSource <object> ();

            manager.RegisterPushNotificationAsync(tileID, tcs.AttachCompletionHandler());
            return(tcs.Task);
        }
Example #29
0
 public static Task SendMessageTaskAsync(this IBandNotificationManager manager, NSUuid tileID, string title, string body, DateTime timeStamp)
 {
     return(manager.SendMessageTaskAsync(tileID, title, body, (NSDate)timeStamp));
 }
Example #30
0
 public static Task SendMessageTaskAsync(this IBandNotificationManager manager, NSUuid tileID, string title, string body, NSDate timeStamp, bool showDialog)
 {
     return(manager.SendMessageTaskAsync(tileID, title, body, timeStamp, showDialog ? MessageFlags.ShowDialog : MessageFlags.None));
 }
Example #31
0
        public static Task SendMessageTaskAsync(this IBandNotificationManager manager, NSUuid tileID, string title, string body, NSDate timeStamp, MessageFlags flags)
        {
            var tcs = new TaskCompletionSource <object> ();

            manager.SendMessageAsync(tileID, title, body, timeStamp, flags, tcs.AttachCompletionHandler());
            return(tcs.Task);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            Title = NSBundle.MainBundle.LocalizedString("Master", "iBeacons Everywhere");

            //Near = UIImage.FromBundle ("Images/square_near");
            //Far = UIImage.FromBundle ("Images/square_far");
            //Immediate = UIImage.FromBundle ("Images/square_immediate");
            //Unknown = UIImage.FromBundle ("Images/square_unknown");

            //_locationManager = new CLLocationManager();
            //_locationManager.RequestAlwaysAuthorization();

            //_beaconRegions = new List<CLBeaconRegion>();
            foreach (var uid in _uuidList)
            {
                var beaconUuid = new NSUuid(uid);
                var beaconRegion = new CLBeaconRegion(beaconUuid, uid);
                beaconRegion.NotifyEntryStateOnDisplay = true;
                beaconRegion.NotifyOnEntry = true;
                beaconRegion.NotifyOnExit = true;

                _beaconRegions.Add(beaconRegion);
            }

            _locationManager.RegionEntered += (object sender, CLRegionEventArgs e) => {

                    var notification = new UILocalNotification ()
                    {
                        AlertBody = string.Format("you have entered the region {0}", e.Region.Identifier)
                    };
                    UIApplication.SharedApplication.CancelAllLocalNotifications();
                    UIApplication.SharedApplication.PresentLocationNotificationNow (notification);
            };

            //_locationManager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => {
            //    _dataSource.Beacons = e.Beacons;
            //    TableView.ReloadData();
            //};

            foreach (var clBeaconRegion in _beaconRegions)
            {
                _locationManager.StartMonitoring(clBeaconRegion);
                _locationManager.StartRangingBeacons(clBeaconRegion);
            }

            TableView.Source = _dataSource = new DataSource (this);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            locationmanager = new CLLocationManager();

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                locationmanager.RequestAlwaysAuthorization();

            beaconUUID = new NSUuid(uuid);
            beaconRegion = new CLBeaconRegion(beaconUUID, beaconMajor, beaconMinor, beaconId);
            beaconRegion.NotifyEntryStateOnDisplay = true;
            beaconRegion.NotifyOnEntry = true;
            beaconRegion.NotifyOnExit = true;

            locationmanager.RegionEntered += (sender, e) =>
            {
                var notification = new UILocalNotification() { AlertBody = "The Xamarin beacon is close by!" };
                UIApplication.SharedApplication.CancelAllLocalNotifications();
                UIApplication.SharedApplication.PresentLocalNotificationNow(notification);

            };

            //create beacon region
            beaconUUID = new NSUuid(uuid);
            beaconRegion = new CLBeaconRegion(beaconUUID, beaconMajor, beaconMinor, beaconId);

            locationmanager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) =>
            {
                if (e.Beacons == null || e.Beacons.Length == 0)
                    return;

                LabelBeacon.Text = "We found: " + e.Beacons.Length + " beacons";

                var beacon = e.Beacons[0];

                switch (beacon.Proximity)
                {
                    case CLProximity.Far:
                        View.BackgroundColor = UIColor.Blue;
                        break;

                    case CLProximity.Near:
                        View.BackgroundColor = UIColor.Yellow;
                        break;

                    case CLProximity.Immediate:
                        View.BackgroundColor = UIColor.Green;
                        break;

                }

                LabelDistance.Text = "We are: " + beacon.Accuracy.ToString("##.000");

                if (beacon.Accuracy <= .1 && beacon.Proximity == CLProximity.Immediate)
                {
                    locationmanager.StopRangingBeacons(beaconRegion);
                    var vc = UIStoryboard.FromName("MainStoryboard", null).InstantiateViewController("FoundViewController");
                    NavigationController.PushViewController(vc, true);
                }

            };

            locationmanager.StartRangingBeacons(beaconRegion);
        }
Example #34
0
 public static bool IsUuidEqual(this NSUuid firstUuid, NSUuid secondUuid)
 {
     return firstUuid.AsString().Equals(secondUuid.AsString(), StringComparison.OrdinalIgnoreCase);
 }
        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);
            }
        }
Example #36
0
 public User GetUser(NSUuid uuid)
 {
     return _userList.Find(u => u.DeviceUuid.IsUuidEqual(uuid));
 }
Example #37
0
		/// <summary>
		/// Rangeds the beacons.
		/// </summary>
		/// <param name="UUID">UUI.</param>
		void RangedBeacons (string UUID)
		{
			
			SystemLogger.Log (SystemLogger.Module.PLATFORM, "RangedBeacons UUID " + UUID);
			if (UUID != null) {
				var uuid = new NSUuid (UUID);
				region = new BeaconRegion (uuid, "BeaconSample");
			} else {
				region = new BeaconRegion (null, "BeaconSample");
			}

			beaconManager.StartRangingBeacons(region);
			//TODO should call other appverse listeners? 
			beaconDict.Clear();
			//beaconArray = new List<Appverse.Core.iBeacon.Beacon> ();


			try{
				// Declare a timer: same steps in C# and VB
				tmr = new Timer();
				tmr.AutoReset = false;
				tmr.Interval = 5000; // 0.1 second
				tmr.Elapsed += timerHandler; // We'll write it in a bit
				tmr.Start(); // The countdown is launched!
			}catch(Exception e){
				SystemLogger.Log (SystemLogger.Module.PLATFORM, "Could not create the timer, STOP mannually. Exception: " + e.Message);
			}


		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            if (!UserInterfaceIdiomIsPhone) {
                openMultipeerBrowser.TouchUpInside += (sender, e) => {
                    StartMultipeerBrowser ();
                };
            } else {
                StartMultipeerAdvertiser ();
            }

            var monkeyUUID = new NSUuid (uuid);
            beaconRegion = new CLBeaconRegion (monkeyUUID, monkeyId);

            beaconRegion.NotifyEntryStateOnDisplay = true;
            beaconRegion.NotifyOnEntry = true;
            beaconRegion.NotifyOnExit = true;

            if (UserInterfaceIdiomIsPhone) {

                InitPitchAndVolume ();

                locationMgr = new CLLocationManager ();

                locationMgr.RequestWhenInUseAuthorization ();

                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 override void ViewDidLoad()
        {
            base.ViewDidLoad();

            uuidTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            uuidTextField.InputView        = new UuidPickerView(uuidTextField);
            uuidTextField.EditingDidBegin += HandleEditingDidBegin;
            uuidTextField.EditingDidEnd   += (sender, e) => {
                uuid = new NSUuid(uuidTextField.Text);
                NavigationItem.RightBarButtonItem = saveButton;
            };

            majorTextField.KeyboardType     = UIKeyboardType.NumberPad;
            majorTextField.ReturnKeyType    = UIReturnKeyType.Done;
            majorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            majorTextField.EditingDidBegin += HandleEditingDidBegin;
            majorTextField.EditingDidEnd   += (sender, e) => {
                major = numberFormatter.NumberFromString(majorTextField.Text);
                NavigationItem.RightBarButtonItem = saveButton;
            };

            minorTextField.KeyboardType     = UIKeyboardType.NumberPad;
            minorTextField.ReturnKeyType    = UIReturnKeyType.Done;
            minorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            minorTextField.EditingDidBegin += HandleEditingDidBegin;
            minorTextField.EditingDidEnd   += (sender, e) => {
                minor = numberFormatter.NumberFromString(minorTextField.Text);
                NavigationItem.RightBarButtonItem = saveButton;
            };

            enabledSwitch.ValueChanged += (sender, e) => {
                enabled = enabledSwitch.On;
            };

            notifyOnEntrySwitch.ValueChanged += (sender, e) => {
                notifyOnEntry = notifyOnEntrySwitch.On;
            };

            notifyOnExitSwitch.ValueChanged += (sender, e) => {
                notifyOnExit = notifyOnExitSwitch.On;
            };

            notifyOnDisplaySwitch.ValueChanged += (sender, e) => {
                notifyOnDisplay = notifyOnDisplaySwitch.On;
            };

            doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (sender, e) => {
                uuidTextField.ResignFirstResponder();
                majorTextField.ResignFirstResponder();
                minorTextField.ResignFirstResponder();
                TableView.ReloadData();
            });

            saveButton = new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, e) => {
                foreach (var region in locationManger.MonitoredRegions)
                {
                    locationManger.StopMonitoring(Runtime.GetNSObject <CLBeaconRegion> (region.Handle));
                }

                if (enabled)
                {
                    var region = Helpers.CreateRegion(uuid, major, minor);
                    locationManger.RequestAlwaysAuthorization();
                    var p = CLLocationManager.Status;
                    if (region != null)
                    {
                        region.NotifyOnEntry             = notifyOnEntry;
                        region.NotifyOnExit              = notifyOnExit;
                        region.NotifyEntryStateOnDisplay = notifyOnDisplay;
                        locationManger.StartMonitoring(region);
                        locationManger.StartRangingBeacons(region);
                        locationManger.RequestState(region);
                    }
                }
                else
                {
                    var region = (CLBeaconRegion)locationManger.MonitoredRegions.AnyObject;
                    if (region != null)
                    {
                        locationManger.StopMonitoring(region);
                    }
                }
                //NavigationController.PopViewController (true);
            });

            NavigationItem.RightBarButtonItem = saveButton;
        }
		public static Task SetPagesTaskAsync (this IBandTileManager manager, PageData[] pageData, NSUuid tileId)
		{
			var tcs = new TaskCompletionSource<object> ();
			manager.SetPagesAsync (pageData, tileId, tcs.AttachCompletionHandler ());
			return tcs.Task;
		}
Example #41
0
 public CXCallAction [] GetPendingCallActions <T> (NSUuid callUuid)
 {
     return(GetPendingCallActions(new Class(typeof(T)), callUuid));
 }
        protected virtual Estimote.BeaconRegion ToNative(BeaconRegion region) {
			var uuid = new NSUuid(region.Uuid);
			Estimote.BeaconRegion native = null;

			if (region.Major > 0 && region.Minor > 0)
				native = new Estimote.BeaconRegion(uuid, region.Major.Value, region.Minor.Value, region.Identifier);

			else if (region.Major > 0)
				native = new Estimote.BeaconRegion(uuid, region.Major.Value, region.Identifier);

			else
				native = new Estimote.BeaconRegion(uuid, region.Identifier);

			native.NotifyEntryStateOnDisplay = true;
			native.NotifyOnEntry = true;
			native.NotifyOnExit = true;

			return native;
        }
Example #43
0
 /// <summary>
 /// Gets the device identifier.
 /// </summary>
 /// <returns>The device identifier as a Guid.</returns>
 /// <param name="id">The device identifier as a NSUuid.</param>
 public static Guid DeviceIdentifierToGuid(NSUuid id)
 {
     return(Guid.ParseExact(id.AsString(), "d"));
 }
Example #44
0
 public virtual CXCallAction[] GetPendingCallActions <T> (NSUuid callUuid) => throw new PlatformNotSupportedException(Constants.UnavailableOnMacOS);
Example #45
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var tmp = new Random();

            #region GUI Item Init


            //Create and add background image
            var background = new UIImageView
            {
                Frame = UIScreen.MainScreen.Bounds,
                Image = UIImage.FromBundle("mainbackground.jpg")
            };


            //Create and add label
            var lblInfo = new UILabel(new RectangleF(260, 60, 300, 60))
            {
                Text      = "Adding and Removing Estimotes",
                TextColor = new UIColor(255, 255, 255, 255),
                Font      = UIFont.FromName("Helvetica-Bold", 15f)
            };


            //Create back button
            var btnBack = new UIButton(UIButtonType.RoundedRect)
            {
                Frame           = new RectangleF(580, 720, 150, 60),
                BackgroundColor = new UIColor(160, 245, 250, 255),
                Font            = UIFont.FromName("Helvetica-Bold", 30f)
            };
            btnBack.SetTitle("Back", UIControlState.Normal);
            btnBack.Layer.CornerRadius = 5f;

            //Create 'add' button
            var btnAdd = new UIButton(UIButtonType.RoundedRect)
            {
                Frame           = new RectangleF(350, 275, 75, 40),
                BackgroundColor = new UIColor(160, 245, 250, 255),
                Font            = UIFont.FromName("Helvetica-Bold", 20f)
            };
            btnAdd.SetTitle("<-", UIControlState.Normal);
            btnAdd.Layer.CornerRadius = 5f;

            //Create sub button
            var btnSub = new UIButton(UIButtonType.RoundedRect)
            {
                Frame           = new RectangleF(350, 375, 75, 40),
                BackgroundColor = new UIColor(160, 245, 250, 255),
                Font            = UIFont.FromName("Helvetica-Bold", 20f)
            };
            btnSub.SetTitle("->", UIControlState.Normal);
            btnSub.Layer.CornerRadius = 5f;

            var btnSave = new UIButton(UIButtonType.RoundedRect)
            {
                Frame           = new RectangleF(580, 820, 150, 60),
                BackgroundColor = new UIColor(160, 245, 250, 255),
                Font            = UIFont.FromName("Helvetica-Bold", 30f),
            };

            btnSave.SetTitle("Save", UIControlState.Normal);
            btnSave.Layer.CornerRadius = 5f;

            var btnAddBeacon = new UIButton(UIButtonType.RoundedRect)
            {
                Frame           = new RectangleF(40, 920, 200, 60),
                BackgroundColor = new UIColor(160, 245, 250, 255),
                Font            = UIFont.FromName("Helvetica-Bold", 20f)
            };

            btnAddBeacon.SetTitle("Add Beacon", UIControlState.Normal);
            btnAddBeacon.Layer.CornerRadius = 5f;

            var btnClearText = new UIButton(UIButtonType.RoundedRect)
            {
                Frame           = new RectangleF(280, 920, 200, 60),
                BackgroundColor = new UIColor(160, 245, 250, 255),
                Font            = UIFont.FromName("Helvetica-Bold", 20f)
            };

            btnClearText.SetTitle("Clear Boxes", UIControlState.Normal);
            btnClearText.Layer.CornerRadius = 5f;

            var txtName = new UITextField()
            {
                Frame           = new RectangleF(40, 720, 200, 60),
                BackgroundColor = new UIColor(255, 255, 255, 255),
                Font            = UIFont.FromName("Helvetica-Bold", 20f),
                Placeholder     = "Name",
                TextAlignment   = UITextAlignment.Center
            };

            var txtExhibit = new UITextField()
            {
                Frame           = new RectangleF(280, 720, 200, 60),
                BackgroundColor = new UIColor(255, 255, 255, 255),
                Font            = UIFont.FromName("Helvetica-Bold", 20f),
                Placeholder     = "Exhibit",
                TextAlignment   = UITextAlignment.Center
            };

            var txtMajor = new UITextField()
            {
                Frame                  = new RectangleF(40, 820, 200, 60),
                BackgroundColor        = new UIColor(255, 255, 255, 255),
                Font                   = UIFont.FromName("Helvetica-Bold", 20f),
                Placeholder            = "Major ID",
                UserInteractionEnabled = false,
                TextAlignment          = UITextAlignment.Center
            };

            //txtMajor.TextColor = new UIColor(100,100,100,255);

            var txtMinor = new UITextField()
            {
                Frame                  = new RectangleF(280, 820, 200, 60),
                BackgroundColor        = new UIColor(255, 255, 255, 255),
                Font                   = UIFont.FromName("Helvetica-Bold", 20f),
                Placeholder            = "Minor ID",
                UserInteractionEnabled = false,
                TextAlignment          = UITextAlignment.Center
            };

            //txtMinor.TextColor = new UIColor(100, 100, 100, 255);

            //Create table for estimotes with no information
            var unsetTable = new UITableView()
            {
                Frame = new RectangleF(530, 100, 200, 500),
                AllowsMultipleSelection = false,
            };

            //Create table for estimotes with information
            var setTable = new UITableView(new RectangleF(40, 100, 200, 500))
            {
                AllowsMultipleSelection = false
            };



            btnSave.TouchUpInside += (sender, args) => CreateXml(setList);
            btnBack.TouchUpInside += (sender, args) => DismissViewController(true, null);

            btnClearText.TouchUpInside += (sender, args) =>
            {
                txtExhibit.Text = "";
                txtMajor.Text   = "";
                txtMinor.Text   = "";
                txtName.Text    = "";
            };

            btnAddBeacon.TouchUpInside += (sender, args) =>
            {
                if (!txtName.HasText)
                {
                    new UIAlertView("No Name!", "Please give the new beacon a name", null, "OK", null).Show();
                }
                else if (!txtExhibit.HasText)
                {
                    new UIAlertView("No Exhibit!", "Please give the new beacon an exhibit", null, "OK", null).Show();
                }
                else
                {
                    foundList.Add(new EstimoteInit(tmp.Next(10000, 99999).ToString(), tmp.Next(10000, 99999).ToString(),
                                                   txtName.Text, txtExhibit.Text));
                    unsetTable.ReloadData();
                }
            };



            //Adding all buttons and tables
            View.Add(background);
            Add(lblInfo);
            Add(btnAdd);
            Add(btnSub);
            Add(btnBack);
            Add(btnSave);
            Add(btnAddBeacon);
            Add(btnClearText);
            Add(txtName);
            Add(txtExhibit);
            Add(txtMajor);
            Add(txtMinor);
            Add(unsetTable);
            Add(setTable);


            #endregion

            //FileHandle(lblInfo);

            #region Estimote Handling

            //Creating estimote initializers
            var manager  = new CLLocationManager();
            var beaconId = new NSUuid("B9407F30-F5F8-466E-AFF9-25556B57FE6D");
            var region   = new CLBeaconRegion(beaconId, "Ranging");

            //Allowing bluetooth access
            manager.RequestAlwaysAuthorization();
            manager.RequestWhenInUseAuthorization();
            manager.PausesLocationUpdatesAutomatically = false;

            //If location is disabled
            if (!CLLocationManager.LocationServicesEnabled)
            {
                lblInfo.Text = "Location Not Enabled";
            }

            //Detecting the estimote beacons
            manager.DidRangeBeacons += (sender, args) =>
            {
                foreach (var s in args.Beacons)
                {
                    var notFound = foundList.SingleOrDefault(a => a.GetMajor().ToString() == s.Major.ToString());
                    if (notFound == null)
                    {
                        foundList.Add(new EstimoteInit(s.Major.ToString(), s.Minor.ToString(), "", ""));
                        GenerateUnsetEstimotes();
                    }
                    unsetTable.ReloadData();
                }
            };


            var unsetSource = new TableController(unsetList, this);
            var setSource   = new TableController(setList, this);

            unsetTable.Source = unsetSource;
            setTable.Source   = setSource;

            unsetSource.OnRowSelected += (sender, args) =>
            {
                txtMajor.Text = unsetSource.tableList[args.indexPath.Row].GetMajor();
                txtMinor.Text = unsetSource.tableList[args.indexPath.Row].GetMinor();
            };

            setSource.OnRowSelected += (sender, args) =>
            {
                txtName.Text    = setSource.tableList[args.indexPath.Row].GetName();
                txtExhibit.Text = setSource.tableList[args.indexPath.Row].GetExhibit();
                txtMajor.Text   = setSource.tableList[args.indexPath.Row].GetMajor();
                txtMinor.Text   = setSource.tableList[args.indexPath.Row].GetMinor();
            };

            txtName.ShouldReturn += delegate
            {
                txtName.ResignFirstResponder();
                return(true);
            };

            txtExhibit.ShouldReturn += delegate
            {
                txtExhibit.ResignFirstResponder();
                return(true);
            };


            //Commence bluetooth detection
            manager.StartMonitoring(region);
            manager.StartRangingBeacons(region);
            manager.StartUpdatingLocation();

            #endregion
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			uuidTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
			uuidTextField.InputView = new UuidPickerView (uuidTextField);
			uuidTextField.EditingDidBegin += HandleEditingDidBegin;
			uuidTextField.EditingDidEnd += (sender, e) => {
				uuid = new NSUuid (uuidTextField.Text);
				NavigationItem.RightBarButtonItem = saveButton;
			};

			majorTextField.KeyboardType = UIKeyboardType.NumberPad;
			majorTextField.ReturnKeyType = UIReturnKeyType.Done;
			majorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
			majorTextField.EditingDidBegin += HandleEditingDidBegin;
			majorTextField.EditingDidEnd += (sender, e) => {
				major = numberFormatter.NumberFromString (majorTextField.Text);
				NavigationItem.RightBarButtonItem = saveButton;
			};

			minorTextField.KeyboardType = UIKeyboardType.NumberPad;
			minorTextField.ReturnKeyType = UIReturnKeyType.Done;
			minorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
			minorTextField.EditingDidBegin += HandleEditingDidBegin;
			minorTextField.EditingDidEnd += (sender, e) => {
				minor = numberFormatter.NumberFromString (minorTextField.Text);
				NavigationItem.RightBarButtonItem = saveButton;
			};

			enabledSwitch.ValueChanged += (sender, e) => {
				enabled = enabledSwitch.On;
			};

			notifyOnEntrySwitch.ValueChanged += (sender, e) => {
				notifyOnEntry = notifyOnEntrySwitch.On;
			};

			notifyOnExitSwitch.ValueChanged += (sender, e) => {
				notifyOnExit = notifyOnExitSwitch.On;
			};

			notifyOnDisplaySwitch.ValueChanged += (sender, e) => {
				notifyOnDisplay = notifyOnDisplaySwitch.On;
			};

			doneButton = new UIBarButtonItem (UIBarButtonSystemItem.Done, (sender, e) => {
				uuidTextField.ResignFirstResponder ();
				majorTextField.ResignFirstResponder ();
				minorTextField.ResignFirstResponder ();
				TableView.ReloadData ();
			});

			saveButton = new UIBarButtonItem (UIBarButtonSystemItem.Save, (sender, e) => {
				if (enabled) {
					var region = Helpers.CreateRegion (uuid, major, minor);
					if (region != null) {
						region.NotifyOnEntry = notifyOnEntry;
						region.NotifyOnExit = notifyOnExit;
						region.NotifyEntryStateOnDisplay = notifyOnDisplay;
						locationManger.StartMonitoring (region);
					}
				} else {
					var region = (CLBeaconRegion)locationManger.MonitoredRegions.AnyObject;
					if (region != null)
						locationManger.StopMonitoring (region);
				}
				NavigationController.PopViewController (true);
			});

			NavigationItem.RightBarButtonItem = saveButton;
		}
Example #47
0
 public virtual void ReportCall(NSUuid uuid, CXCallUpdate update) => throw new PlatformNotSupportedException(Constants.UnavailableOnMacOS);
		public static Task RemovePagesTaskAsync (this IBandTileManager manager, NSUuid tileId)
		{
			var tcs = new TaskCompletionSource<object> ();
			manager.RemovePagesAsync (tileId, tcs.AttachCompletionHandler ());
			return tcs.Task;
		}
Example #49
0
 public virtual void ReportCall(NSUuid uuid, NSDate?dateEnded, CXCallEndedReason endedReason) => throw new PlatformNotSupportedException(Constants.UnavailableOnMacOS);
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			this.Title = "Configure";

			enabledSwitch.ValueChanged += (sender, e) => {
				enabled = enabledSwitch.On;
			};

			uuidTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
			uuidTextField.InputView = new UuidPickerView (uuidTextField);
			uuidTextField.EditingDidBegin += HandleEditingDidBegin;
			uuidTextField.EditingDidEnd += (sender, e) => {
				uuid = new NSUuid (uuidTextField.Text);
				NavigationItem.RightBarButtonItem = saveButton;
			};
			uuidTextField.Text = uuid.AsString ();

			majorTextField.KeyboardType = UIKeyboardType.NumberPad;
			majorTextField.ReturnKeyType = UIReturnKeyType.Done;
			majorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
			majorTextField.EditingDidBegin += HandleEditingDidBegin;
			majorTextField.EditingDidEnd += (sender, e) => {
				major = numberFormatter.NumberFromString (majorTextField.Text);
				NavigationItem.RightBarButtonItem = saveButton;
			};

			minorTextField.KeyboardType = UIKeyboardType.NumberPad;
			minorTextField.ReturnKeyType = UIReturnKeyType.Done;
			minorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
			minorTextField.EditingDidBegin += HandleEditingDidBegin;
			minorTextField.EditingDidEnd += (sender, e) => {
				minor = numberFormatter.NumberFromString (minorTextField.Text);
				NavigationItem.RightBarButtonItem = saveButton;
			};

			measuredPowerTextField.KeyboardType = UIKeyboardType.NumberPad;
			measuredPowerTextField.ReturnKeyType = UIReturnKeyType.Done;
			measuredPowerTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
			measuredPowerTextField.EditingDidBegin += HandleEditingDidBegin;
			measuredPowerTextField.EditingDidEnd += (sender, e) => {
				power = numberFormatter.NumberFromString (measuredPowerTextField.Text);
				NavigationItem.RightBarButtonItem = saveButton;
			};

			doneButton = new UIBarButtonItem (UIBarButtonSystemItem.Done, (sender, e) => {
				uuidTextField.ResignFirstResponder ();
				majorTextField.ResignFirstResponder ();
				minorTextField.ResignFirstResponder ();
				measuredPowerTextField.ResignFirstResponder ();
				TableView.ReloadData ();
			});

			saveButton = new UIBarButtonItem (UIBarButtonSystemItem.Save, (sender, e) => {
				if (peripheralManager.State < CBPeripheralManagerState.PoweredOn) {
					new UIAlertView ("Bluetooth must be enabled", "To configure your device as a beacon", null, "OK", null).Show ();
					return;
				}

				if (enabled) {
					CLBeaconRegion region = Helpers.CreateRegion (uuid, major, minor);
					if (region != null)
						peripheralManager.StartAdvertising (region.GetPeripheralData (power));
				} else {
					peripheralManager.StopAdvertising ();
				}

				NavigationController.PopViewControllerAnimated (true);
			});

			NavigationItem.RightBarButtonItem = saveButton;
		}
Example #51
0
 public virtual void ReportConnectingOutgoingCall(NSUuid uuid, NSDate?dateStartedConnecting) => throw new PlatformNotSupportedException(Constants.UnavailableOnMacOS);