前提・実現したいこと
Xamarin.Forms(ios)において、アプリがバックグラウンドの状態でibeaconの検出を行いたいのですが、Beaconのmajorなどの情報が取得できません。
どのようにしたらいいか分かる方いらっしゃったら教えていただきたいです。
発生している問題・エラーメッセージ
アプリがフォアグランドで動いている際はDidRangeBeaconsが呼ばれBeaconsに値が入っており情報は取得できています。
バックグラウンドの際もRegionEnteredが呼ばれ、その後DidRangeBeaconsも呼ばれてはいるのですが、Beaconsに値が入っていない状態です。
該当のソースコード
locationmanager = new CLLocationManager(); locationmanager.RequestAlwaysAuthorization(); beaconUUID = new NSUuid("xxx_xxx_xxx"); beaconId = "xxxxxxxxx" beaconRegion = new CLBeaconRegion(beaconUUID, beaconId); beaconRegion.NotifyEntryStateOnDisplay = true; beaconRegion.NotifyOnEntry = true; beaconRegion.NotifyOnExit = true; locationmanager.RegionEntered += (object sender, CLRegionEventArgs e) => { System.Diagnostics.Debug.WriteLine("beacon RegionEntered : " + e.Region.Identifier); }; locationmanager.RegionLeft += (object sender, CLRegionEventArgs e) => { }; locationmanager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => { if (e.Beacons.Length > 0) { CLBeacon beacon = e.Beacons[0]; var info = "beacon.Proximity " + beacon.Proximity.ToString() + " / beacon.Major " + beacon.Major + " / beacon.Minor " + beacon.Minor; System.Diagnostics.Debug.WriteLine(info); } }; locationmanager.StartMonitoring(beaconRegion); locationmanager.StartRangingBeacons(beaconRegion);
あなたの回答
tips
プレビュー