Ibeacon dependency service

Hi,
I have this very simple iBeacon reder working i IOS with help of a dependency service and 3 functions.
StartLooking is the important one that takes in a page to report back to, then starts the reading and when it finds beacons it calls a function on the incoming page and send a list of the found beacons.

So as you see very simple functionality but I can't understand how to make the same thing on a android dependency, anyone that can help me, get started?

/magnus

    [assembly: Xamarin.Forms.Dependency(typeof(BeaconListener))]

    namespace xxxx.iOS
    {
        public class BeaconListener:IBeacon
        {
            CLLocationManager lm;
            ScanningPage mp;
            CLBeaconRegion region;

            public BeaconListener()
            {

            }

            public void StartLooking(ScanningPage mPage)
            {
                mp = mPage;
                NSUuid beaconId = new NSUuid("00000000-0000-0000-0000-000000000000");
                region = new CLBeaconRegion(beaconId, "xxxxx");

                lm = new CLLocationManager();

                lm.RequestWhenInUseAuthorization();

                lm.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) =>
                    {
                        if (e.Beacons.Length > 0)
                        {
                            List<Beacon> lb = new List<Beacon>();

                            for (var i = 0; i < e.Beacons.Length;i++) 
                            {
                                if (e.Beacons[i].Accuracy > 0)
                                {
                                    var b = new Beacon();
                                    b.minor = e.Beacons[i].Minor.ToString();
                                    b.acc = e.Beacons[i].Accuracy;
                                    b.prox = e.Beacons[i].Proximity.ToString();
                                    lb.Add(b);
                                }
                            }
                            mp.reciveBeacon(lb);
                        }

                    };
                lm.StartRangingBeacons(region);

            }

            public void StopLooking()
            {
                lm.StopRangingBeacons(region);
            }

            public void ResumeLooking() { 
                lm.StartRangingBeacons(region);
            }
        }
    }
Tagged:

Answers

  • MagnusWallonMagnusWallon USMember ✭✭

    Please cant someone help me with this? I need to get this working today!

  • MagnusWallonMagnusWallon USMember ✭✭

    i still havn't found a solution to this, please can't someone give a little help so I understand how this works in Android?

Sign In or Register to comment.