ios - Using iPhones as iBeacons -


i trying app work whereby phone emits ibeacon signal , nearby phones able detect in background , callback method. phone broadcasting signal , phone b monitoring in background , calls method. here code setting up:

var centralmanager: cbcentralmanager! var peripheralmanager: cbperipheralmanager = cbperipheralmanager() var locationmanager: cllocationmanager = cllocationmanager() let uuid: nsuuid = nsuuid(uuidstring: "dcef54a2-31eb-467f-af8e-350fb641c97b")!  override func viewdidload() {     super.viewdidload()     self.locationmanager.delegate = self     self.locationmanager.requestalwaysauthorization()     self.centralmanager = cbcentralmanager(delegate: self, queue: nil)     self.peripheralmanager = cbperipheralmanager(delegate: self, queue: nil)     let beaconregion = clbeaconregion(proximityuuid: uuid, identifier: "device")     locationmanager.startmonitoringforregion(beaconregion) 

this code using advertising , monitoring beacons:

func locationmanager(manager: cllocationmanager, didenterregion region: clregion) {     print("beacon has been found")     print(region) }  func peripheralmanagerdidupdatestate(peripheral: cbperipheralmanager) {     print("pm state updated")     let advertisingdata = [cbadvertisementdatalocalnamekey:"device", cbadvertisementdataserviceuuidskey: uuid]     peripheralmanager.startadvertising(advertisingdata) } 

as want devices same uuid, not specifying major , minor, major , minor of phone b method calls when monitors phone a.

my problem phone able start advertising phone b not seem recognise devices.

the code sets bluetooth advertisement not setting ibeacon transmission:

let advertisingdata = [cbadvertisementdatalocalnamekey:"device", cbadvertisementdataserviceuuidskey: uuid] peripheralmanager.startadvertising(advertisingdata) 

that code sets advertise bluetooth le service service id of dcef54a2-31eb-467f-af8e-350fb641c97b. isn't same ibeacon advertisement manufacturer advertisement, proximityuuid (different service uuid) along major , minor identifier. set ibeacon transmission proximityuuid dcef54a2-31eb-467f-af8e-350fb641c97b major 1 minor 1 this:

let advertisingdata = beacon.peripheraldatawithmeasuredpower(nil) dictionary peripheralmanager.startadvertising(advertisingdata as? [string : anyobject]) 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -