예제 #1
0
    void Monitor()
    {
        // don't advertise and monitor at the same time
        StopAdvertise();

        if (isMonitoring)
        {
            Log("Already monitoring.");
            return;
        }

        if (locationManager == null)
        {
            locationManager = new CLLocationManager();
        }

        locationManager.DidStartMonitoring += DidStartMonitoringForRegion;
        locationManager.DidEnter           += DidEnterRegion;
        locationManager.DidExit            += DidExitRegion;
        locationManager.DidRangeBeacons    += DidRangeBeacons;
        locationManager.StartMonitoring(beaconRegion);
        locationManager.StartRangingBeaconsInRegion(beaconRegion);

        Log("Monitoring.");
        isMonitoring = true;
    }