3

I am able to read and write data from my iOS app(Central). Just after Delegate connectPeripheral:periphal is called, OS gives an alert asking for authentication PIN with two buttons "Cancel" and "Pair".

I am not able to get any notification when user presses "Cancel" or "Pair" button. I am also not able to detect if the pairing is successful or not.

self.peripheral.state always returns 2 (connected)

Michał Ciuba
  • 7,876
  • 2
  • 33
  • 59
  • For cancel there is a delegate. But when pair is successful there is no delegate. Asked the same question to Apple guys and waiting for there response. Also when user press "Cancel" or do not enter any pin for 30 seconds, or enter wrong pin then same delegate gets called. And the error code in delegate is same for all there cases. I am waiting for Apple to fix the issue in upcoming releases. –  Apr 06 '16 at 13:06
  • Can you please give some more details about which delegate method is called when user press "Cancel" button during pairing request. In this question [In CBPeripheralManager, how to know if user push a cancel button when it's trying to pairing](http://stackoverflow.com/questions/34131132/in-cbperipheralmanager-how-to-know-if-user-push-a-cancel-button-when-its-tryin), Oleshko has suggested that maybe didFailToConnectPeripheral method of CBCentralManagerDelegate is called. I tried that but it is not getting called. – Sunil Kumar May 23 '16 at 11:18
  • @Sunil, didDisconnectPeripheral: delegate gets called when you press cancel button. –  May 26 '16 at 10:11
  • I agree, but this delegate is called for any reasons peripheral is disconnected.Is their any way to know that user has promptly press the"Cancel" button in the alert view or is their any delegate to know alert view for pair/cancel has been shown. – Sunil Kumar May 26 '16 at 11:52
  • @Sunil, in didDisconnectPeripheral, there is an error section. At the minute, error code is same if user press "Cancel" or peripheral gets disconnected for any other reason. I have reported the issue to Apple that the error code should be different, they informed me that their engineers will look into it. But there is not other way to get the action on "Cancel" button of authentication alert. I suggest you put a generic alert in "didDisconnectPeripheral". So user will get the alert if they press "Cancel" or peripheral gets disconnected for any other reason. –  May 27 '16 at 07:21
  • For me "didDisconnectPeripheral" is not getting called when we press cancel. Do you guys have any idea. – Mahesh Verma Jan 12 '17 at 10:27

1 Answers1

0

I have done some research to handling Cancel event of pairing popup but unfortunately apple doesn't provide any delegate to handle it.

taserghar
  • 340
  • 3
  • 15