iOS CoreBluetooth Notifications - ios

Squirrels on my balcony eat my jalapeƱos. I pointed a camera to the place where my jalapeƱos grow and using a simple motion detection software on my computer on the balcony I know when squirrels show up.
I figured out how to establish a Bluetooth Low Energy communication between my computer and my iPhone (my computer is the central and the smartphone is a peripheral).
Is there a way how to invoke a push notificaiton using Bluetooth Low Energy that shows up on my phone whenever my camera detects a squirrel? I want to know if it is possible without an Internet connection.

In a word, no. Push notifications require an internet connection. However, do you specifically want APNS, or do you just want a way to wake up your app and display a message to the user when you receive a BLE message from your computer?
I believe you can set up your iPhone app to get BLE notices from the background. If you can do that then you can code your app to trigger a LOCAL notification (different from a push notification, but similar in terms of the UX)

Related

How to receive & send Bluetooth data on IOS when the phone is locked

I'm helping a friend with an iOS app and we have run into a bit of a snag.
Basically, the app needs to be able to send and receive BLE data while the app is backgrounded and the phone is locked. This interaction needs to be pretty rapid (<500ms or so).
The actual connecting and disconnecting of the BLE accessory will be handled within the app while foregrounded, but the send/receive needs to occur while the app is backgrounded and phone locked.
This essentially amounts to streaming data back and forth between the BLE accessory and the phone while the phone does some processing.
The basic user journey:
User opens app and connects to BLE accessory in-app
User backgrounds the app and locks the phone
BLE accessory mic picks up audio and sends audio data to phone
Phone receives and processes data while locked
Phone sends data back to BLE accessory
We have it fully working while the app is foregrounded. Is this possible to do while backgrounded/locked? If so, are there any resources you could point me to?
Thanks in advance :)
Yes this should be doable in the background, but you need to add code to support this feature as it is not enabled by default. Have a look at the link below, specifically the section "Adding Support for State Preservation and Restoration":-
Core Bluetooth Background Processing for iOS Apps
BLE device keep connection with iPhone when application terminates

PunchThrough LightBlue how do you make a virtual device send a notification?

I'm developing an Android app that is a BLE central. I don't yet have access to the peripheral device. This would be a typical scenario for a virtual device simulator like LightBlue. I can scan and connect client-peri and I can enable notifications by writing the CCCD. If I use LightBlue's Time profile I can get Current Time characteristic notifications once per second. What I need to do is to add a custom characteristic and make that send notifications either at a specified interval or preferrably when pressing a button. How do I do that?
I'm also all ears for other methods or apps that can help me. I can't program my own peripheral app because I only have an iPhone and I don't have access to a development environment for iOS at the moment.
Hoping for insights!
thanks!

Mi Band 1S vibration on incoming call handling on iOS

SO. Initial data:
Device Xiaomi Mi Band 1 or 1S
Device paired with iPhone
Xiaomi iOS app has option "Vibrate on incoming calls"
How they implement it? It continue works if you reboot device or force quit an app. It is unusual for default BLE background. Any ideas how this app handle events?
For people who vote for closing this question. This is a very interesting issue which require some specific knowledge about bluetooth and background. For example there are three bluetooth background modes: external-accessory for old-school non-ble blueooth, bluetooth-central and bluetooth-peripheral. I have done a lot of experiments about last two. But it does not work as you expected after documentation reading. I have found few questions about this topic here on SO. All of them report about pure predictable for bluetooth background. And after all hours on this issue you see on Mi Band and them official absolutely legal app in App Store. And this App keeps connection or has some other "magic" mechanism to handle calls and initiate reaction on device. At a minimum it is curious. Is it? At a minimum it is useful for developers who works with peripheral devices.
It looks like Apple Notification Center Service (ANCS) integration, not Bluetooth Background + Core Telephony.
The purpose of the Apple Notification Center Service (ANCS) is to give Bluetooth accessories (that connect to iOS devices through a Bluetooth low-energy link) a simple and convenient way to access many kinds of notifications that are generated on iOS devices.
Documentation
CategoryIDIncomingCall is about incoming call

Activating an iOS app when Bluetooth connection connects

Is such a thing possible? I know certain apps such as VOIP apps have permission to run constantly, but I'm uncertain my app idea would be allowed to always run.
It depends on what you mean by "Activating an app".
You can operate as a Bluetooth Central in background mode and your app can receive notifications that a Bluetooth Low Energy service has been detected (if you are scanning for that service) or a device has connected (if you have a pending connect for that device).
You can then interact with the peripheral briefly (transfer a small amount of information for example) or display a notification to the user, but you cannot bring your app to the foreground preempting whatever the user is currently doing.
This project demonstrates CoreBluetooth background connection - https://github.com/paulw11/BTBackground

iOS and Low Power Bluetooth

We were looking for a few roles regarding the Bluetooth LE in iOS, but we could not find them. I have a few questions for anyone who is already using it:
I have read here that there is the ability to listen in the background for the signals, is that right? if so, can i get a signal and open that app from background ?
The other way, can my app run in the background and at some point (lets say when the app gets a notification from alarm) send LE signal without even open the app ?
(Its reasonable that yes, because the iPhone DOES call delegate function, that i can write a LE into it, isn't it?)
Does LE Bluetooth control any iPhone operation(s) outside the relevant app?
Does the Apple docs has some kind of ordered roles for the LE?
Yes. But you can't bring the app to the foreground. You can do some background processing and post a local notification.
Not from an alarm, because the alarm would notify the user, not the app. Possibly from a push notification but that would be a bit weird.
Depends. iPhone can act as Central and Peripheral so it could.
? (You mean Central and Peripheral roles?).

Resources