You do not receive special notification when the central one connects to the peripheral service provided by your application. You can infer a connection from the following CBPeripheralManagerDelegate called methods -
didSubscribeToCharacteristicdidReceiveReadRequestdidReceiveWriteRequest
If you received a subscription through didSubscribeToCharacteristic , you can conclude that you disconnect when you receive a corresponding call to didUnsubscribeFromCharacteristic . If the central device does not use subscriptions, then you do not have indications that they are disabled - you simply will not receive more read / write requests.
You cannot refuse a connection to the central one. You can set the encryption requirement for one or more of your characteristics. This then initiates the pin-based pairing process when the central first tries to read / write / notify about this property.
You can also implement some authentication procedure where the central part must answer the call / write a password for the characteristic, etc., before answering these central other read / write requests.
source share