/// <summary>
 /// On beacon changed
 /// </summary>
 public async Task OnStatusChanged(BeaconRegionState newState, BeaconRegion region)
 {
     App.AddLog("Beacon Status changed: " + region.Uuid.ToString() + " | " + newState.ToString());
     if (newState == BeaconRegionState.Entered || newState == BeaconRegionState.Exited)
     {
         await processBeaconId(region.Uuid.ToString(), newState);
     }
 }
Exemple #2
0
        public async Task OnStatusChanged(BeaconRegionState newStatus, BeaconRegion region)
        {
            var msg = newStatus == BeaconRegionState.Entered
                ? "I see you"
                : "Hey! Where did you go?";

            await this.notifications.Send("Beacons", msg);
        }
Exemple #3
0
 void FireDelegate(BeaconRegionState newState, BeaconRegion region)
 {
     try
     {
         this.beaconDelegate.OnStatusChanged(newState, region);
     }
     catch (Exception ex)
     {
         Log.Write(ex);
     }
 }
Exemple #4
0
 public async void OnStatusChanged(BeaconRegionState newStatus, BeaconRegion region)
 {
     await this.conn.InsertAsync(new BeaconEvent
     {
         Identifier = region.Identifier,
         Uuid       = region.Uuid,
         Major      = region.Major,
         Minor      = region.Minor,
         Entered    = newStatus == BeaconRegionState.Entered,
         Date       = DateTime.UtcNow
     });
 }
 async void Invoke(CLRegion region, BeaconRegionState status)
 {
     if (region is CLBeaconRegion native)
     {
         var beaconRegion = new BeaconRegion(
             native.Identifier,
             native.ProximityUuid.ToGuid(),
             native.Major?.UInt16Value,
             native.Minor?.UInt16Value
             );
         await this.services.RunDelegates <IBeaconMonitorDelegate>(
             x => x.OnStatusChanged(status, beaconRegion)
             );
     }
 }
        /// <summary>
        /// The beaconId
        /// </summary>
        private async Task processBeaconId(string beaconId, BeaconRegionState state)
        {
            var beacon = App.AppSettings.Beacons.FirstOrDefault(o => o.Id == beaconId);

            if (beacon != null && beacon.Enabled)
            {
                App.AddLog("Beacon ID Found: " + beaconId);
                _ = await App.ApiService.HandleSwitch(beacon.SwitchIDX, beacon.SwitchPassword, state == BeaconRegionState.Entered? 1 : 0, beacon.Value, beacon.IsScene);

                if (App.AppSettings.BeaconNotificationsEnabled)
                {
                    App.AddLog("Creating notification for : " + beacon.Name);
                    CrossLocalNotifications.Current.Show(state == BeaconRegionState.Entered ? AppResources.geofence_location_entering.Replace("%1$s", beacon.Name) : AppResources.geofence_location_leaving.Replace("%1$s", beacon.Name),
                                                         state == BeaconRegionState.Entered ? AppResources.geofence_location_entering_text : AppResources.geofence_location_leaving_text);
                }
            }
            else
            {
                App.AddLog("beacon ID not registered: " + beaconId);
            }
        }
 void Invoke(CLRegion region, BeaconRegionState status)
 {
     try
     {
         var native = region as CLBeaconRegion;
         if (native != null)
         {
             var beaconRegion = new BeaconRegion(
                 native.Identifier,
                 native.ProximityUuid.ToGuid(),
                 native.Major?.UInt16Value,
                 native.Minor?.UInt16Value
                 );
             this.bdelegate?.OnStatusChanged(status, beaconRegion);
         }
     }
     catch (Exception ex)
     {
         Log.Write(ex);
     }
 }
Exemple #8
0
 public Task OnStatusChanged(BeaconRegionState newStatus, BeaconRegion region)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
 void Invoke(CLRegion region, BeaconRegionState status) => Dispatcher.Execute(async() =>
Exemple #10
0
 void Invoke(CLRegion region, BeaconRegionState status) => Dispatcher.ExecuteBackgroundTask(async() =>