i doing beacon ranging using core location uuid, major & minor in app. after ranging need connect beacon using core bluetooth api. using estimote beacon in application.
the estbeaconconnection class you're looking for. can use initwithbeacon initializer , pass clbeacon object got ranging:
let bc = estbeaconconnection(beacon: mybeacon, delegate: self, startimmediately: true)
this'll initiate connection process.
the delegate should implement estbeaconconnectiondelegate protocol. when connection established, you'll call beaconconnectiondidsucceed, , can start writing new settings beacon:
func beaconconnectiondidsucceed(connection: estbeaconconnection!) { connection.writemajor(123) { (newmajor, error) in if (error != nil) { println("successfully wrote new major: \(newmajor)") } else { println("didn't write new major, error \(error)") } connection.disconnect() } }
it's idea implement beaconconnectiondidfailwitherror
delegate—should go south, you'll know it.
finally, since can connect , change settings of own beacons, need authenticate before attempting connect:
estcloudmanager.setupappid("appid", andapptoken: "app token")
you can generate app token on https://cloud.estimote.com.
Comments
Post a Comment