iBeacon app not detecting location of beacon properly

98 views Asked by At

I'm developing ibeacon receiver app. It is not using location properly i guess and it is not detecting the beacon... I've already seen lot of solution but nothing works thats why am asking again...

Here is my code

self.uuid = [[NSUUID alloc] initWithUUIDString:myuuid];
self.major = 1;
self.minor = 1;
self.region = [[CLBeaconRegion alloc] initWithProximityUUID:self.uuid major:1 minor:1 identifier:@"com.appcoda.testregion"];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
[self.locationManager requestAlwaysAuthorization];

I downloaded an app from http://www.appcoda.com/ios7-programming-ibeacons-tutorial/ to act as beacon

1

There are 1 answers

6
Parth Adroja On

Your code lacks the monitoring and ranging methods. You need to create region in which you want to detect the beacon.

let beaconRegion = CLBeaconRegion(proximityUUID: item.uuid,
                                            major: item.majorValue,
                                            minor: item.minorValue,
                                       identifier: item.name)

And then you need to start monitoring for the region and you will get the beacons in the delegate of ranging method.

  let beaconRegion = beaconRegion
  locationManager.startMonitoringForRegion(beaconRegion)
  locationManager.startRangingBeaconsInRegion(beaconRegion)