Bhupinder Singh
Bhupinder Singh

Reputation: 284

iOS Check for Connected Peripheral - Xamarin

Hi I have created Core Bluetooth app which connects to peripheral. In my app, i have login page, connect to device page and further more pages.Now, When user login to the app first time, user needs to connect to the device first time which works perfectly fine but if user logout or login again i don't want to show connect to device option to the user. I want the device automatically connected to the app. Is there any event i should listening for ? I have tried to utilize RetrievedConnectedPeripherals event of central manager but this does not seems to be invoke by the app.

Upvotes: 0

Views: 480

Answers (1)

Etan
Etan

Reputation: 17564

One basic hint when working with Xamarin: you still have the same APIs to learn as when programming in native. Therefore, you should also look out for generic CoreBluetooth help, and not Xamarin-specific answers - you will find more resources this way!

You will have to store the CBPeripheral's identifier in a persistent store (NSUserDefaults for example). Then you will have to call RetrievePeripherals, to get a CBPeripheral instance back, and simply connect it like you did the first time. RetrievedConnectedPeripherals is deprecated as of iOS 7 and has been replaced by a synchronous method.

You should also check out Apple's documentation and Programming Guide to get started.

Upvotes: 1

Related Questions