示例#1
0
        private BeaconManager InitializeBeaconManager()
        {
            // Enable the BeaconManager
            BeaconManager bm = BeaconManager.GetInstanceForApplication(Xamarin.Forms.Forms.Context);

            #region Set up Beacon Simulator if testing without a BLE device
            var beaconSimulator = new BeaconSimulator();
            beaconSimulator.CreateBasicSimulatedBeacons();
            BeaconManager.BeaconSimulator = beaconSimulator;
            #endregion

            var iBeaconParser = new BeaconParser();
            //	Estimote > 2013
//			iBeaconParser.SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24");
            iBeaconParser.SetBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24");

//			bm.BeaconParsers.Add(iBeaconParser);

            if (bm.BeaconParsers.Count == 1)
            {
                bm.BeaconParsers.Add(iBeaconParser);
            }

            _monitorNotifier.EnterRegionComplete             += EnteredRegion;
            _monitorNotifier.ExitRegionComplete              += ExitedRegion;
            _monitorNotifier.DetermineStateForRegionComplete += DeterminedStateForRegionComplete;
            _rangeNotifier.DidRangeBeaconsInRegionComplete   += RangingBeaconsInRegion;

            //			region1 = new AltBeaconOrg.BoundBeacon.Region("myUniqueBeaconId1", Identifier.Parse("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A"), null, null);
            region1 = new AltBeaconOrg.BoundBeacon.Region("myUniqueBeaconId1", Identifier.Parse("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A"), null, null);
            //			region2 = new AltBeaconOrg.BoundBeacon.Region ("Prompt2", Identifier.Parse ("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A"), null, null);
            //			region3 = new AltBeaconOrg.BoundBeacon.Region ("Prompt3", Identifier.Parse("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A"), null, null);
            //			region4 = new AltBeaconOrg.BoundBeacon.Region ("Prompt4", Identifier.Parse("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A"), null, null);
            _emptyRegion = new AltBeaconOrg.BoundBeacon.Region("myEmptyBeaconId", null, null, null);

            bm.SetBackgroundMode(false);
            bm.Bind((IBeaconConsumer)Xamarin.Forms.Forms.Context);

            return(bm);
        }
		private BeaconManager InitializeBeaconManager()
		{
			// Enable the BeaconManager 
			BeaconManager bm = BeaconManager.GetInstanceForApplication(Xamarin.Forms.Forms.Context);

			#region Set up Beacon Simulator if testing without a BLE device
			var beaconSimulator = new BeaconSimulator();
			beaconSimulator.CreateBasicSimulatedBeacons();
			BeaconManager.BeaconSimulator = beaconSimulator;
			#endregion

			var iBeaconParser = new BeaconParser();
			//	Estimote > 2013
//			iBeaconParser.SetBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24");
			iBeaconParser.SetBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24");

//			bm.BeaconParsers.Add(iBeaconParser);

			if (bm.BeaconParsers.Count == 1) {
				bm.BeaconParsers.Add(iBeaconParser);
			}

			_monitorNotifier.EnterRegionComplete += EnteredRegion;
			_monitorNotifier.ExitRegionComplete += ExitedRegion;
			_monitorNotifier.DetermineStateForRegionComplete += DeterminedStateForRegionComplete;
			_rangeNotifier.DidRangeBeaconsInRegionComplete += RangingBeaconsInRegion;

			//			region1 = new AltBeaconOrg.BoundBeacon.Region("myUniqueBeaconId1", Identifier.Parse("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A"), null, null);
			region1 = new AltBeaconOrg.BoundBeacon.Region ("myUniqueBeaconId1", Identifier.Parse ("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A"), null, null);
			//			region2 = new AltBeaconOrg.BoundBeacon.Region ("Prompt2", Identifier.Parse ("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A"), null, null);
			//			region3 = new AltBeaconOrg.BoundBeacon.Region ("Prompt3", Identifier.Parse("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A"), null, null);
			//			region4 = new AltBeaconOrg.BoundBeacon.Region ("Prompt4", Identifier.Parse("DF7E1C79-43E9-44FF-886F-1D1F7DA6997A"), null, null);
			_emptyRegion = new AltBeaconOrg.BoundBeacon.Region("myEmptyBeaconId", null, null, null);

			bm.SetBackgroundMode(false);
			bm.Bind((IBeaconConsumer)Xamarin.Forms.Forms.Context);

			return bm;
		}