void FireDelegate(GeofenceState state, GeofenceRegion region)
 {
     try
     {
         this.gdelegate.OnStatusChanged(state, region);
     }
     catch (Exception ex)
     {
         Log.Write(ex);
     }
 }
Example #2
0
        public async override void PublishGeofence(Geoposition position, GeofenceState state)
        {
            // string geofence info
            string geofence = String.Format(PUBLISH_GEOFENCE_JSON_FORMAT,
                                            position.Coordinate.Latitude,
                                            position.Coordinate.Longitude,
                                            (state == GeofenceState.Entered));

            HttpResponseMessage resp = null;

            // public geofence
            resp = await this.httpClient.PostAsync(HTTP_GEOFENCE_PATH, new StringContent(geofence));
        }
Example #3
0
        internal static PositionLogEntry FromFenceDetails(
            GeofenceState newState, Geoposition position)
        {
            PositionLogEntry entry = new PositionLogEntry()
            {
                Date      = DateTimeOffset.Now,
                Latitude  = position.Coordinate.Latitude,
                Longitude = position.Coordinate.Longitude,
                Altitude  = position.Coordinate.Altitude ?? 0.0d,
                State     = newState
            };

            return(entry);
        }
Example #4
0
        public async void OnStatusChanged(GeofenceState newStatus, GeofenceRegion region)
        {
            await this.conn.InsertAsync(new GeofenceEvent
            {
                Identifier = region.Identifier,
                Entered    = newStatus == GeofenceState.Entered,
                Date       = DateTime.Now
            });

            await this.notifications.Send(new Notification
            {
                Title   = "Geofences",
                Message = $"{region.Identifier} was {newStatus}"
            });
        }
Example #5
0
        public override void PublishGeofence(Geoposition position, GeofenceState state)
        {
            // string geofence info
            string geofence = String.Format(PUBLISH_GEOFENCE_JSON_FORMAT,
                                            position.Coordinate.Latitude,
                                            position.Coordinate.Longitude,
                                            (state == GeofenceState.Entered));

            // MQTT client up, running and connected
            if ((this.mqttClient != null) && (this.mqttClient.IsConnected))
            {
                // public geofence
                this.mqttClient.Publish(MQTT_GEOFENCE_TOPIC, Encoding.UTF8.GetBytes(geofence));
            }
        }
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            thisTaskInstance = taskInstance;

            // This is for me to remember to mention that Deferral is needed if there are async operations in the background task
            deferral = taskInstance.GetDeferral();

            string ExceptionData = "None";
            try
            {
                // Get reports for geofences state changes
                foreach (GeofenceStateChangeReport report in GeofenceMonitor.Current.ReadReports())
                {
                    GeofenceState state = report.NewState;
                    Geofence geofence = report.Geofence;

                    var item = await SampleDataSource.GetItemAsync(geofence.Id);


                    // If we've entered a particular geofence, show message for that geofence's id
                    if (state == GeofenceState.Entered)
                    {
                        // Show message for the given geofence enter event
                        string geofenceEnterMessage = "BG Approaching " + item.Subtitle;

                        // Create a toast to tell the user about the event
                        SendToastBG(geofenceEnterMessage);
                        // Or do stuff under the covers, such as update info, change something in the phone, send message, etc
                    }

                    // If we've exited a particular geofence, show message for that geofence's id
                    else if (state == GeofenceState.Exited)
                    {
                        // Show message for the given geofence exit event
                        string geofenceExitMessage = "BG Leaving " + item.Subtitle;
                        // Create a toast to tell the user about the event
                        //SendToastBG(geofenceExitMessage);
                        // Or do stuff under the covers, such as check out, change something in the phone, send message, etc
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionData = ex.Message;
            }

            deferral.Complete();
        }
        private async void Current_StatusChanged(GeofenceMonitor sender, object args)
        {
            var reports = sender.ReadReports();

            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                foreach (GeofenceStateChangeReport report in reports)
                {
                    GeofenceState state = report.NewState;

                    Geofence geofence       = report.Geofence;
                    string eventDescription = string.Format("{0} ({1})", geofence.Id, state.ToString());

                    Debug.WriteLine(eventDescription);
                }
            });
        }
Example #8
0
        public async Task OnStatusChanged(GeofenceState newStatus, GeofenceRegion region)
        {
            var e = new GeofenceEvent
            {
                Id          = Guid.NewGuid().ToString(),
                DateCreated = DateTimeOffset.UtcNow,

                Identifier = region.Identifier,
                Entered    = newStatus == GeofenceState.Entered
            };

            await this.repository.Set(e.Id, e);

            if (!this.jobManager.IsRunning)
            {
                await this.jobManager.RunJobAsTask(Constants.GeofenceJobIdentifer);
            }
        }
        async void Broadcast(CLLocationManager manager, CLRegion region, GeofenceState status)
        {
            if (region is CLCircularRegion native)
            {
                var geofence = await this.repository.Get(native.Identifier);

                if (geofence != null)
                {
                    await this.delegates.Value.RunDelegates(x => x.OnStatusChanged(status, geofence));

                    if (geofence.SingleUse)
                    {
                        await this.repository.Remove(geofence.Identifier);

                        manager.StopMonitoring(native);
                    }
                }
            }
        }
Example #10
0
 public async Task OnStatusChanged(GeofenceState newStatus, GeofenceRegion region)
 {
     if (newStatus == GeofenceState.Entered)
     {
         await this.notifications.Send(new Notification
         {
             Title   = "WELCOME!",
             Message = "you entered the geofence region " + region.Identifier
         });
     }
     else
     {
         await this.notifications.Send(new Notification
         {
             Title   = "GOODBYE!",
             Message = "You exited the geofence region " + region.Identifier
         });
     }
 }
Example #11
0
        /// <summary>
        /// Inform the user about when entering or exiting the geofence
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void EnterFence(GeofenceMonitor sender, object e)
        {
            var reports = sender.ReadReports();

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                foreach (GeofenceStateChangeReport report in reports)
                {
                    GeofenceState state = report.NewState;

                    Geofence geofence = report.Geofence;

                    if (state == GeofenceState.Removed)
                    {
                        GeofenceMonitor.Current.Geofences.Remove(geofence);
                    }
                    else if (state == GeofenceState.Entered)
                    {
                        foreach (Place place in _app.Places)
                        {
                            if (place.Id.ToString() == geofence.Id)
                            {
                                var dia = new MessageDialog("You have entered - " + place.Kind.ToString());
                                await dia.ShowAsync();
                            }
                        }
                    }
                    else if (state == GeofenceState.Exited)
                    {
                        foreach (Place place in _app.Places)
                        {
                            if (place.Id.ToString() == geofence.Id)
                            {
                                var dia = new MessageDialog("You have left - " + place.Kind.ToString());
                                await dia.ShowAsync();
                            }
                        }
                    }
                }
            });
        }
Example #12
0
        public async void OnGeofenceStateChanged(GeofenceMonitor sender, object e)
        {
            var reports = sender.ReadReports();

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                foreach (GeofenceStateChangeReport report in reports)
                {
                    GeofenceState state = report.NewState;

                    Geofence geofence       = report.Geofence;
                    string eventDescription = GetTimeStampedMessage(geofence.Id);

                    eventDescription += " (" + state.ToString();

                    if (state == GeofenceState.Removed)
                    {
                        eventDescription += "/" + report.RemovalReason.ToString() + ")";

                        AddEventDescription(eventDescription);

                        // remove the geofence from the client side geofences collection
                        Remove(geofence);

                        // empty the registered geofence listbox and repopulate
                        geofenceCollection.Clear();

                        FillRegisteredGeofenceListBoxWithExistingGeofences();
                    }
                    else if (state == GeofenceState.Entered || state == GeofenceState.Exited)
                    {
                        // NOTE: You might want to write your app to take particular
                        // action based on whether the app has internet connectivity.

                        eventDescription += ")";

                        AddEventDescription(eventDescription);
                    }
                }
            });
        }
        public async void OnGeofenceStateChanged(GeofenceMonitor sender, object e)
        {
            var reports = sender.ReadReports();

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                foreach (GeofenceStateChangeReport report in reports)
                {
                    GeofenceState state     = report.NewState;
                    Geofence geofence       = report.Geofence;
                    string eventDescription = geofence.Id + " " + DateTime.Now.ToString("T") + " (" + state.ToString();

                    if (state == GeofenceState.Removed)
                    {
                        eventDescription += "/" + report.RemovalReason.ToString() + ")";
                        AddEventDescription(eventDescription);

                        // remove the geofence from the monitor
                        geofenceMonitor.Geofences.Remove(geofence);

                        // Remove the geofence from the list box.
                        foreach (ListBoxItem item in RegisteredGeofenceListBox.Items)
                        {
                            if (item.Tag == geofence)
                            {
                                RegisteredGeofenceListBox.Items.Remove(item);
                                break;
                            }
                        }
                    }
                    else if (state == GeofenceState.Entered || state == GeofenceState.Exited)
                    {
                        // NOTE: You might want to write your app to take particular
                        // action based on whether the app has internet connectivity.

                        eventDescription += ")";
                        AddEventDescription(eventDescription);
                    }
                }
            });
        }
        /// <summary>
        /// The GeofenceId
        /// </summary>
        private async Task processGeofenceId(string geofenceId, GeofenceState state)
        {
            var geofence = App.AppSettings.Geofences.FirstOrDefault(o => o.Id == geofenceId);

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

                if (App.AppSettings.GeofenceNotificationsEnabled)
                {
                    App.AddLog("Creating notification for : " + geofence.Name);
                    CrossLocalNotifications.Current.Show(state == GeofenceState.Entered ? AppResources.geofence_location_entering.Replace("%1$s", geofence.Name) : AppResources.geofence_location_leaving.Replace("%1$s", geofence.Name),
                                                         state == GeofenceState.Entered ? AppResources.geofence_location_entering_text : AppResources.geofence_location_leaving_text);
                }
            }
            else
            {
                App.AddLog("Geofence ID not registered: " + geofenceId);
            }
        }
Example #15
0
        protected void Current_GeofenceStateChanged(GeofenceMonitor sender, object args)
        {
            var reports = sender.ReadReports();

            foreach (var report in reports)
            {
                GeofenceState state = report.NewState;

                Geofence geofence = report.Geofence;

                if (state == GeofenceState.Removed)
                {
                    // remove the geofence from the client side geofences collection
                    this.RemoveGeofence(geofence);
                }
                else if (state == GeofenceState.Entered || state == GeofenceState.Exited)
                {
                    this.PublishGeofence(report.Geoposition, state);
                }
            }
        }
Example #16
0
        //geofence状态改变时的回调凜数
        private void stateChangedCallback(Geofence g, GeofenceState s)
        {
            Debug.WriteLine(string.Format("æ‚šå·²{0}“{1}”区域", s == GeofenceState.Entered ? "进入" : "犻匀", g.Id));

            string message = "";

            if (Global.Current.Globalization.geo_CurrentLanguage == Global.Current.Globalization.geo_Chinese)
            {
                message = string.Format("æ‚šå·²{0}“{1}”区域", s == GeofenceState.Entered ? "进入" : "犻匀", g.Id);
            }
            else
            {
                message = string.Format("You have {0} the geofence region of \"{1}\"", s == GeofenceState.Entered ? "entered" : "left", g.Id);
            }
            //匹Toast消息
            Global.Current.Notifications.CreateToastNotifier("", message);
            //曎新锁屏信息
            Global.Current.Notifications.UpdateBadgeWithNumber(1);
            //曎新磁莎信息
            Global.Current.Notifications.CreateTileWide310x150PeekImage01("Geofence", message);
        }
        private async void OnGeofenceStateChanged(GeofenceMonitor sender, object args)
        {
            var reports = sender.ReadReports();
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                foreach (GeofenceStateChangeReport report in reports)
                {
                    GeofenceState state = report.NewState;

                    Geofence geofence = report.Geofence;

                    if (state == GeofenceState.Removed)
                    {
                        // Remove the geofence from the geofences collection.
                        GeofenceMonitor.Current.Geofences.Remove(geofence);
                    }
                    else if (state == GeofenceState.Entered)
                    {
                        // Your app takes action based on the entered event.

                        // NOTE: You might want to write your app to take a particular
                        // action based on whether the app has internet connectivity.
                        System.Diagnostics.Debug.WriteLine("You have entered geofence!");
                        showNotificationPin(report.Geoposition.Coordinate.Point.Position.Latitude, report.Geoposition.Coordinate.Point.Position.Latitude);
                    }
                    else if (state == GeofenceState.Exited)
                    {
                        // Your app takes action based on the exited event.
                        // NOTE: You might want to write your app to take a particular
                        // action based on whether the app has internet connectivity.
                        System.Diagnostics.Debug.WriteLine("You have exited geofence!");
                        if (_dialogsList.Count > 0)
                        {
                            _dialogsList[0].Hide();
                        }
                    }
                }
            });
        }
        private void GetGeofenceStateChangedReports()
        {
            GeofenceMonitor monitor      = GeofenceMonitor.Current;
            Geoposition     posLastKnown = monitor.LastKnownGeoposition;

            string geofenceItemEvent = null;

            // Retrieve a vector of state change reports
            var reports = GeofenceMonitor.Current.ReadReports();

            foreach (var report in reports)
            {
                GeofenceState state = report.NewState;
                geofenceItemEvent = report.Geofence.Id;

                if (state == GeofenceState.Removed)
                {
                    GeofenceRemovalReason reason = report.RemovalReason;
                    if (reason == GeofenceRemovalReason.Expired)
                    {
                        geofenceItemEvent += " (Removed/Expired)";
                    }
                    else if (reason == GeofenceRemovalReason.Used)
                    {
                        geofenceItemEvent += " (Removed/Used)";
                    }
                }
                else if (state == GeofenceState.Entered)
                {
                    geofenceItemEvent += " (Entered)";
                }
                else if (state == GeofenceState.Exited)
                {
                    geofenceItemEvent += " (Exited)";
                }
            }
            // NOTE: Other notification mechanisms can be used here, such as Badge and/or Tile updates.
            DoToast(geofenceItemEvent);
        }
Example #19
0
        private async void Current_GeofenceStateChanged(GeofenceMonitor sender, object args)
        {
            var Reports = sender.ReadReports();

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                foreach (GeofenceStateChangeReport report in Reports)
                {
                    GeofenceState state = report.NewState;

                    Geofence geofence = report.Geofence;

                    if (state == GeofenceState.Entered)
                    {
                        ShowMessage("You are pretty close to your room");
                    }
                    else if (state == GeofenceState.Exited)
                    {
                        ShowMessage("You have left pretty far away from your room");
                    }
                }
            });
        }
Example #20
0
        private async void OnGeofenceStateChanged(GeofenceMonitor sender, object args)
        {
            var reports = sender.ReadReports();

            await CoreApplication.MainView.Dispatcher.RunAsync
                (CoreDispatcherPriority.Normal, () =>
            {
                foreach (GeofenceStateChangeReport report in reports)
                {
                    GeofenceState state = report.NewState;
                    Geofence geofence   = report.Geofence;

                    if (state == GeofenceState.Entered)
                    {
                        GeofenceEnteredEventTriggered?.Invoke(geofence);
                    }
                    else if (state == GeofenceState.Exited)
                    {
                        GeofenceExitedEventTriggered?.Invoke(geofence);
                    }
                }
            });
        }
        //GeofenceMonitor.Current.GeofenceStateChanged回调
        private void Current_GeofenceStateChanged(GeofenceMonitor sender, object args)
        {
            var geoReports = sender.ReadReports();

            foreach (var report in geoReports)
            {
                Geofence      geo      = report.Geofence;
                GeofenceState newState = report.NewState;
                GeofenceStateChangedCallback callback;
                try
                {
                    callbacks.TryGetValue(GetGeofenceIndex(geo), out callback);
                    if (callback != null)
                    {
                        callback(geo, newState);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        public async Task OnStatusChanged(GeofenceState newStatus, GeofenceRegion region)
        {
            await Application.Current.MainPage.DisplayAlert(newStatus.ToString(), $"{region.Identifier}", "Ok");

            Debug.WriteLine("Je bent binnen");

            if (newStatus == GeofenceState.Entered)
            {
                Debug.WriteLine("Je bent binnen");
                await this.notifications.Send(new Notification
                {
                    Title   = "WELCOME!",
                    Message = "It is good to have you back " + region.Identifier
                });
            }
            else
            {
                await this.notifications.Send(new Notification
                {
                    Title   = "GOODBYE!",
                    Message = "You will be missed at " + region.Identifier
                });
            }
        }
Example #23
0
 internal GeofenceStateChangeReport(Geofence geofence, Geoposition geoposition, GeofenceState newstate)
 {
     _geofence    = geofence;
     _geoposition = geoposition;
     _newState    = newstate;
 }
Example #24
0
        private void GetGeofenceStateChangedReports(Geoposition pos)
        {
            _geofenceBackgroundEvents.Clear();

            FillEventCollectionWithExistingEvents();

            GeofenceMonitor monitor = GeofenceMonitor.Current;

            Geoposition posLastKnown = monitor.LastKnownGeoposition;

            Windows.Globalization.Calendar calendar = new Windows.Globalization.Calendar();
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatterLongTime;
            formatterLongTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{hour.integer}:{minute.integer(2)}:{second.integer(2)}", new[] { "en-US" }, "US", Windows.Globalization.CalendarIdentifiers.Gregorian, Windows.Globalization.ClockIdentifiers.TwentyFourHour);

            bool eventOfInterest = true;

            // NOTE TO DEVELOPER:
            // Registered geofence events can be filtered out if the
            // geofence event time is stale.
            DateTimeOffset eventDateTime = pos.Coordinate.Timestamp;

            calendar.SetToNow();
            DateTimeOffset nowDateTime  = calendar.GetDateTime();
            TimeSpan       diffTimeSpan = nowDateTime - eventDateTime;

            long deltaInSeconds = diffTimeSpan.Ticks / oneHundredNanosecondsPerSecond;

            if (true == eventOfInterest)
            {
                if ((posLastKnown.Coordinate.Point.Position.Latitude != pos.Coordinate.Point.Position.Latitude) ||
                    (posLastKnown.Coordinate.Point.Position.Longitude != pos.Coordinate.Point.Position.Longitude))
                {
                    UpdateInforamtion.WipeGeolocDataFromAppData();
                }

                if (true == eventOfInterest)
                {
                    string geofenceItemEvent   = null;
                    int    numEventsOfInterest = 0;

                    // Retrieve a vector of state change reports
                    var reports = GeofenceMonitor.Current.ReadReports();

                    foreach (var report in reports)
                    {
                        GeofenceState state = report.NewState;
                        geofenceItemEvent = report.Geofence.Id + " " + formatterLongTime.Format(eventDateTime);

                        if (state == GeofenceState.Removed)
                        {
                            GeofenceRemovalReason reason = report.RemovalReason;
                            if (reason == GeofenceRemovalReason.Expired)
                            {
                                geofenceItemEvent += " (Removed/Expired)";
                            }
                            else if (reason == GeofenceRemovalReason.Used)
                            {
                                geofenceItemEvent += " (Removed/Used)";
                            }
                        }
                        else if (state == GeofenceState.Entered)
                        {
                            geofenceItemEvent += " (Entered)";
                        }
                        else if (state == GeofenceState.Exited)
                        {
                            geofenceItemEvent += " (Exited)";
                        }

                        AddGeofenceEvent(geofenceItemEvent);

                        ++numEventsOfInterest;
                    }

                    if (true == eventOfInterest && 0 != numEventsOfInterest)
                    {
                        SaveExistingEvents();

                        // NOTE: Other notification mechanisms can be used here, such as Badge and/or Tile updates.
                        DoToast(numEventsOfInterest, geofenceItemEvent);
                    }
                }
            }
        }
Example #25
0
 public GeofenceCurrentStatus(GeofenceRegion region, GeofenceState status)
 {
     this.Region = region;
     this.Status = status;
 }
Example #26
0
 protected virtual void SetState(string geofenceId, GeofenceState state)
 {
     this.CurrentStates[geofenceId] = state;
     this.RaisePropertyChanged(nameof(this.CurrentStates));
 }
 internal GeofenceStateChangeReport(Geofence geofence, Geoposition geoposition, GeofenceState newstate)
 {
     _geofence = geofence;
     _geoposition = geoposition;
     _newState = newstate;
 }
Example #28
0
 public Task OnStatusChanged(GeofenceState newStatus, GeofenceRegion region)
 {
     return(Task.CompletedTask);
 }
Example #29
0
        private void GetGeofenceStateChangedReports(Geoposition pos)
        {
            geofenceBackgroundEvents.Clear();

            FillEventCollectionWithExistingEvents();

            GeofenceMonitor monitor = GeofenceMonitor.Current;

            Geoposition posLastKnown = monitor.LastKnownGeoposition;

            Windows.Globalization.Calendar calendar = new Windows.Globalization.Calendar();
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatterLongTime;
            formatterLongTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{hour.integer}:{minute.integer(2)}:{second.integer(2)}", new[] { "en-US" }, "US", Windows.Globalization.CalendarIdentifiers.Gregorian, Windows.Globalization.ClockIdentifiers.TwentyFourHour);

            bool eventOfInterest = true;

            // NOTE TO DEVELOPER:
            // These events can be filtered out if the
            // geofence event time is stale.
            DateTimeOffset eventDateTime = pos.Coordinate.Timestamp;

            calendar.SetToNow();
            DateTimeOffset nowDateTime = calendar.GetDateTime();

            TimeSpan diffTimeSpan = nowDateTime - eventDateTime;

            long deltaInSeconds = diffTimeSpan.Ticks / oneHundredNanosecondsPerSecond;

            // NOTE TO DEVELOPER:
            // If the time difference between the geofence event and now is too large
            // the eventOfInterest should be set to false.

            if (eventOfInterest)
            {
                // NOTE TO DEVELOPER:
                // This event can be filtered out if the
                // geofence event location is too far away.
                if ((posLastKnown.Coordinate.Point.Position.Latitude != pos.Coordinate.Point.Position.Latitude) ||
                    (posLastKnown.Coordinate.Point.Position.Longitude != pos.Coordinate.Point.Position.Longitude))
                {
                    // NOTE TO DEVELOPER:
                    // Use an algorithm like the Haversine formula or Vincenty's formulae to determine
                    // the distance between the current location (pos.Coordinate)
                    // and the location of the geofence event (latitudeEvent/longitudeEvent).
                    // If too far apart set eventOfInterest to false to
                    // filter the event out.
                }

                if (eventOfInterest)
                {
                    string geofenceItemEvent = null;

                    int numEventsOfInterest = 0;

                    // Retrieve a vector of state change reports
                    var reports = GeofenceMonitor.Current.ReadReports();

                    foreach (GeofenceStateChangeReport report in reports)
                    {
                        GeofenceState state = report.NewState;

                        geofenceItemEvent = report.Geofence.Id + " " + formatterLongTime.Format(eventDateTime);

                        if (state == GeofenceState.Removed)
                        {
                            GeofenceRemovalReason reason = report.RemovalReason;

                            if (reason == GeofenceRemovalReason.Expired)
                            {
                                geofenceItemEvent += " (Removed/Expired)";
                            }
                            else if (reason == GeofenceRemovalReason.Used)
                            {
                                geofenceItemEvent += " (Removed/Used)";
                            }
                        }
                        else if (state == GeofenceState.Entered)
                        {
                            geofenceItemEvent += " (Entered)";
                        }
                        else if (state == GeofenceState.Exited)
                        {
                            geofenceItemEvent += " (Exited)";
                        }

                        AddGeofenceEvent(geofenceItemEvent);

                        ++numEventsOfInterest;
                    }

                    if (eventOfInterest && (0 != numEventsOfInterest))
                    {
                        SaveExistingEvents();

                        // NOTE: Other notification mechanisms can be used here, such as Badge and/or Tile updates.
                        DoToast(numEventsOfInterest, geofenceItemEvent);
                    }
                }
            }
        }
 public async Task OnStatusChanged(GeofenceState newStatus, GeofenceRegion region)
 {
 }
 void Broadcast(CLLocationManager manager, CLRegion region, GeofenceState status) => Dispatcher.ExecuteBackgroundTask(async() =>