Ejemplo n.º 1
0
		static async void OnBeaconRegionStatusChanged(object sender, BeaconRegionStatusChangedEventArgs args) {
			App.Data.Insert(new BeaconPing {
				Identifier = args.Region.Identifier,
				Uuid = args.Region.Uuid,
				Major = args.Region.Major ?? 0,
				Minor = args.Region.Minor ?? 0,
				DateCreated = DateTime.Now,
				Type = args.IsEntering ? BeaconPingType.MonitorEntering : BeaconPingType.MonitorExiting
			});

			if (!args.IsEntering)
				Notifications.Instance.Send("Exited Region", $"You have exited {args.Region.Identifier}");
			else {
                try {
                    var beacons = await EstimoteManager.Instance.FetchNearbyBeacons(args.Region);
                    foreach (var beacon in beacons) {
			            App.Data.Insert(new BeaconPing {
				            Identifier = args.Region.Identifier,
				            Uuid = beacon.Uuid,
				            Major = beacon.Major,
				            Minor = beacon.Minor,
				            DateCreated = DateTime.Now,
				            Type = App.IsBackgrounded ? BeaconPingType.RangedBackground : BeaconPingType.RangedForeground
			            });
                    }
                    Notifications.Instance.Send("Entered Region", $"You have entered {args.Region.Identifier}");
                }
                catch (Exception ex) {
                    Debug.WriteLine(ex);
                }
            }
		}
Ejemplo n.º 2
0
		async void OnBeaconRegionStatusChanged(object sender, BeaconRegionStatusChangedEventArgs e) {
			await Task.Delay(500); // let data get logged on App.cs first
			this.LoadData();
		}