0

Home application show the below alert when we are trying to add accessory.

I have also used the HomeKit framwork in my application and want to show the alert when user try to add accessory.

What kind of changes i need to do to show the same alert in app?

Screenshot of Home App

iDev
  • 531
  • 1
  • 5
  • 15
  • For Bluetooth: https://stackoverflow.com/a/21696963/4417447 For Wifi Service: https://stackoverflow.com/a/29487450/4417447 – santak May 29 '17 at 06:45

1 Answers1

0

For Bluetooth in iOS, you have CBPeripheralManager (in CoreBluetooth Framework). To check for bluetooth connection, you declare your class as delegate of CBPeripheralManager then create a local variable:

var myBTManager = CBPeripheralManager(delegate: self, queue: nil, options: nil)

then, your class must implement the callback to get noticed when your Bluetooth is enabled or disabled. The code below is extracted from my project which is for Beacon manager

//BT Manager
func peripheralManagerDidUpdateState(peripheral: CBPeripheralManager!) {
    println(__FUNCTION__)
    if peripheral.state == CBPeripheralManagerState.PoweredOn {
        println("Broadcasting...")
        //start broadcasting
        myBTManager!.startAdvertising(_broadcastBeaconDict)
    } else if peripheral.state == CBPeripheralManagerState.PoweredOff {
        println("Stopped")
        myBTManager!.stopAdvertising()
    } else if peripheral.state == CBPeripheralManagerState.Unsupported {
        println("Unsupported")
    } else if peripheral.state == CBPeripheralManagerState.Unauthorized {
        println("This option is not allowed by your application")
    }
 }

And for Wifi, take a look at this Github: https://github.com/ashleymills/Reachability.swift

Source Answer : - Detecting if Wifi or Bluetooth is turned on or off by the user

Pushpendra
  • 1,492
  • 1
  • 17
  • 33