Crossgeofence Xamarin.forms ложные уведомления - PullRequest
0 голосов
/ 14 января 2020

Я разрабатываю небольшое приложение с функцией Geofences CrossGeeks / GeofencePlugin.

На android все работает хорошо, в то время как с iOS (Iphone 7 плюс iOS 13.2.3) когда я активирую мониторинг для всех регионов, метод OnRegionStateChanged вызывается для всех регионов, даже если они находятся за границей.

это мой код:

Geofences geofences = new Geofences();
    var GeofencesList = new List<Geofences>();
    GeofencesList = await geofences.GetGeofences();

    try
    {
        foreach (Geofences geofence in GeofencesList)
        {

            GeofenceCircularRegion region = new GeofenceCircularRegion(geofence.IdentificativoGeoFence, Convert.ToDouble(geofence.Latitudine), Convert.ToDouble(geofence.Longitudine), Convert.ToDouble(geofence.Raggio))
            {
                NotifyOnEntry = true,
                NotifyOnExit = true,
                ShowEntryNotification = true,
                ShowExitNotification = true,
                NotificationEntryMessage = "Sei entrato nella regione " + geofence.IdentificativoGeoFence,
                NotificationExitMessage = "Sei uscito dalla regione " + geofence.IdentificativoGeoFence
            };
            ListOfRegion.Add(region);
        }
        CrossGeofence.Current.StartMonitoring(ListOfRegion);

        if (CrossGeofence.Current.IsMonitoring == true)
        {
            Monitoring.Text = string.Format("Monitoraggio attivo ({0} Geofences)", CrossGeofence.Current.Regions.Count());
        }
        else
        {
            Monitoring.Text = "Monitoraggio non attivo";
        }
        FermaSessione.IsEnabled = true;
        ApriSessione.IsEnabled = false;
    }
    catch (Exception ex)
    {
        await DisplayAlert("Errore", ex.Message, "OK");
    }

Это и есть геозона Класс:

class Geofences
    {
        public int idGeofence;
        public string IdentificativoGeoFence;
        public string Session;
        public double Latitudine;
        public double Longitudine;
        public double Raggio;
        public string Username;
        public bool RegistraIN;
        public bool RegistraOUT;
        public int RegistraStazionamentoPerMinutes;
        public string Repeat;
        public string Notify;

        public async Task<List<Geofences>> GetGeofences()
        {
            HttpClient client = new HttpClient();
            var response = await client.GetStringAsync("https://...");
            var geofences = JsonConvert.DeserializeObject<List<Geofences>>(response);
            return geofences;
        }
    }

Знаете, как это решить? Спасибо!

...