public void OnExitedRegion(Region region) { if (_beacons.Any(beacon => RegionsAreEqual(beacon.Region, region))) { ExitedRegion?.Invoke(this, region); } }
public void Connect(List <EstimoteBeacon> beacons, TimeSpan foregroundScanPeriod, TimeSpan foregroundWaitTime, TimeSpan backgroundScanPeriod, TimeSpan backgroundWaitTime) { _beacons = beacons; SensusContext.Current.MainThreadSynchronizer.ExecuteThreadSafe(() => { #if __ANDROID__ _beaconManager = new BeaconManager(Application.Context); _beaconManager.SetMonitoringListener(this); _beaconManager.SetForegroundScanPeriod((long)foregroundScanPeriod.TotalMilliseconds, (long)foregroundWaitTime.TotalMilliseconds); _beaconManager.SetBackgroundScanPeriod((long)backgroundScanPeriod.TotalMilliseconds, (long)backgroundWaitTime.TotalMilliseconds); _beaconManager.Connect(this); #elif __IOS__ _beaconManager = new BeaconManager(); _beaconManager.EnteredRegion += (sender, e) => { if (_beacons.Any(beacon => RegionsAreEqual(beacon.Region, e.Region))) { EnteredRegion?.Invoke(this, e.Region); } }; _beaconManager.ExitedRegion += (sender, e) => { if (_beacons.Any(beacon => RegionsAreEqual(beacon.Region, e.Region))) { ExitedRegion?.Invoke(this, e.Region); } }; foreach (EstimoteBeacon beacon in _beacons) { _beaconManager.StartMonitoringForRegion(beacon.Region); } #endif }); }