/// <summary>
 /// On geofence changed
 /// </summary>
 public async Task OnStatusChanged(GeofenceState newState, GeofenceRegion region)
 {
     App.AddLog("Geofence Status changed: " + region.Identifier + " | " + newState.ToString());
     if (newState == GeofenceState.Entered || newState == GeofenceState.Exited)
     {
         await processGeofenceId(region.Identifier, newState);
     }
 }
Exemple #2
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 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
                });
            }
        }
        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);
                    }
                }
            });
        }
        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);
                }
            });
        }