Reputation: 57
I have managed to achieve this for Android and I hope there is a solution for iOS. I'm using Plugin.BLE and I'm trying to create event listener which should sit in Xamarin iOS > AppDelegate level which will detect IBleCentralManagerDelegate.UpdatedState changes. Reason: I would like to trap BLE states while user performs PIN pairing
So far I have:
internal class SimpleCBCentralManagerDelegate : CBCentralManagerDelegate
{
public override void UpdatedState(CBCentralManager central)
{
var state = central.State;
}
public override void FailedToConnectPeripheral(CBCentralManager central, CBPeripheral peripheral, NSError error)
{
base.FailedToConnectPeripheral(central, peripheral, error);
}
public override void ConnectedPeripheral(CBCentralManager central, CBPeripheral peripheral)
{
base.ConnectedPeripheral(central, peripheral);
}
[Export("centralManager:didUpdateANCSAuthorizationForPeripheral:")]
public void DidUpdateAncsAuthorization(CBCentralManager central, CBPeripheral peripheral)
{
var test = peripheral.IsConnected;
}
}
I'm getting only status poweredOn or poweredOff and other statuses or events are not firing.
Upvotes: 0
Views: 234