Broadcast event on IOS - ios

I am new to iOS dev and wanted to learn what's Android's broadcast event equivalent in iPhone. I am trying to find Bluetooth connect/disconnect broadcast event on iOS. I am looking for Bluetooth connectivity between iPhone and any other Bluetooth based device and I want to launch my app on successful connection with Bluetooth and close the app on Bluetooth disconnect.
Example in swift would be awesome.
Thank you.

Look into NSNotificationCenter and do some more research into Bluetooth notifications in iOS. You shouldn't need any examples here to figure it out.

Related

Ios Application connected in Background with device

i have an application that is connected with a chip by bluetooth.
Device and phone are constantly connected to calculate the distance between them by bluetooth delay in reply.
App is working fine in foreground.
When i go background the app is still running, but cannot connect to the device.
I already tried to fix with this guide: Core Bluetooth Programming Guide
but i didnt made it.
Some suggestion?
You need to introduce more detail.
Your app will not run in background mode even bluetooth connection is on.
But your app still have a chance to execute some code in a short time if some bluetooth event happen.
Connection lost.
Notification received.
If your application work like anti-loss bluetooth tag, you need
Enable background in iOS app.
Write your code in core bluetooth delegate.
And One reminder: Calculate distance based on bluetooth relay is not smart. Bluetooth communication is not designed to support this kind of feature.
It work on license free 2.4G band and human body has big impact on it.

How to get notification when user connects to bluetooth device in IOS settings?

sorry for my bad english
I am developing an app on IOS 9.2. One of the app functions is to get information about bluetooth devices.
I have already managed to monitor bluetooth devices nearby using CoreBluetooth framework and connect to one of them. It works in background mode too. The problem is how to get notification when user connects to device from IOS settings?
Thanks for any help

How to detect in my app device is currently connected to vehicle Carplay

I googled lot but i did not get any hint. I want callback in my app when device is connect to carplay using cable.
I tried EAAccessory framework (EAAccessoryDidConnectNotification
and EAAccessoryDidDisconnectNotification) for detection. But i can't differentiate device used for carplay or USB(charging purpose), I am getting callback for both event.
Please give me any solution.
Thanks in advance.
Since iOS 12, if you're working on a CarPlay navigation app, you can utilize methods of CPApplicationDelegate. CarPlay audio apps are not provided with such facilities.

ANCS Notifications in Core Bluetooth Framework

I am working with a BLE device which shows all the notifications received on my iOS device. I have set up all the ANCS part form the BLE Device side and it is working successfully.
I am trying to implement a functionality which will include the use of a switch in the settings screen named as "Allow notifications".
As the name suggest, If switched off then the ANCS notifications should not transfer from my device to the BLE device.
This approach is being taken so as the micro controller has to process a lot less information in case the notifications are off.
Please suggest a way if anything is possible from iOS side as we do not have any control over the ANCS notification in Core Bluetooth framework.
Thanks in advance.
I think the easiest way will be to send a command over BLE from the iOS device to the BLE Device to "STOP" listening for ACNS. You could send a special notification class you use for commands to stop listening. You could then re-enable delivery by sending a "GO" command to the BLE Device.
This way you can turn off and on the ability of the BLE Device to listen or not to the ANCS from iOS.

Connect iOS device to Bluetooth device with SPP

I'm working on one watch which shows iOS device notification like..
Display Installed app notification
Display Call notification
Display Message notification.. etc
I have read some articles and came to know about GATT and ANCS, and this two itself enough to display iOS device notification on other bluetooth device.
Generic Attribute(GATT) Profile : https://developer.bluetooth.org/TechnologyOverview/Pages/GATT.aspx
Apple Notification Center Service(ANCS):
https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Introduction/Introduction.html
Is that mean I do not need any iOS application to handle iOS device notification?
Currently my watch is built up with SPP, do I need to make any modification in that?
I also came to know that I have to apply for MFi Program(https://developer.apple.com/programs/mfi/).
is MFi necessary for My watch with the idea I have mentioned above?
Any suggestion will be appreciated.
Thanks in advance
SPP is classic BT whereas ANCS uses BTLE.
ANCS is free to use.
https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Specification/Specification.html#//apple_ref/doc/uid/TP40013460-CH1-SW18

Resources