Using iPhone as iBeacon Transmitter

I’m trying to set up my iPhone to broadcast an iBeacon signal for another iPhone to pick up. The iPhone that’s supposed to pick up the signal is working, but I can’t get the other iPhone to broadcast the signal.

I’m following this tutorial:

  • Feeding parsed data to RKMapperOperation throws NSUnknownKeyException
  • Problems with transitionWithView and animateWithDuration
  • How to set Action for UIButton in UITableViewCell
  • Why does a custom UIButton image does not resize in Interface Builder?
  • Undo/Redo for drawing in iOS
  • iOS :Call a method in specific time
  • And here’s my code:

    import CoreBluetooth
    import CoreLocation
    class iBeaconTransmission: NSObject, CBPeripheralManagerDelegate {
        var localBeacon: CLBeaconRegion!
        var beaconPeripheralData: NSDictionary!
        var peripheralManager: CBPeripheralManager!
        func initLocalBeacon() {
            if localBeacon != nil {
            let localBeaconUUID = "placeholder"
            let localBeaconMajor: CLBeaconMajorValue = 123
            let localBeaconMinor: CLBeaconMinorValue = 456
            let uuid = NSUUID(UUIDString: localBeaconUUID)!
            localBeacon = CLBeaconRegion(proximityUUID: uuid, major: localBeaconMajor, minor: localBeaconMinor, identifier: "placeholder")
            self.beaconPeripheralData = self.localBeacon.peripheralDataWithMeasuredPower(nil)
            self.peripheralManager = CBPeripheralManager(delegate: self, queue: nil, options: nil)
        func stopLocalBeacon() {
            peripheralManager = nil
            beaconPeripheralData = nil
            localBeacon = nil
        func peripheralManagerDidUpdateState(peripheral: CBPeripheralManager) {
            print("Peripheral Manager")
            if peripheral.state == .PoweredOn {
                peripheralManager.startAdvertising(beaconPeripheralData as! [String: AnyObject]!)
            } else if peripheral.state == .PoweredOff {

    Another note, location services is already set to always authorized.

    “Peripheral Manager” is also never being printed, so the function that’s in isn’t being called for some reason.


    Solutions Collect From Internet About “Using iPhone as iBeacon Transmitter”

    Fixed. I moved the code into a view controller and called initLocalBeacon() in the viewDidLoad function.