iOS React to iBeacon enter event with sending own iBeacon signal - ios

I'm in the process of developing an iOS app that uses iBeacons.
I understand that my app can get woken up to the background when an enter event is triggered (when the iPhone detects a iBeacon with a certain UUID).
Can I use this to send back a beacon signal myself? (All while the phone is locked)
I know that my app would only have a few seconds in the background after being woken up by the enter event, but normally this should be enough time to send a beacon signal.
Any help is highly appreciated. Thanks in advance.

Unfortunately, an iOS device cannot send a standard iBeacon transmission when in the background. While you can execute the code to do so, and iOS will transmit, background transmissions will.not be detectable as iBeacons by other devices.
Why? CoreBluetooth uses a proprietary technique to roll up all Bluetooth advertisements of background applications into a single advertisement. This is designed to work with advertising Gatt services, and it has the side effect of breaking the iBeacon format.

Related

How to keep scanning for BLE sensors and Identify sensor keyEvent while iOS App is terminated

How to keep scanning for BLE Sensors while App is in the terminated status in IOS App. While App is running I am able to manage multiple sensors. However, when App is terminated, how to keep listening to an advertisement and connect the Sensor to App not running status.
State preservation and State Restoration is implemented. Background mode Bluetooth-Central is turned on
I want to achieve it like Tile and Chipolo are doing in the terminate state.
What you are trying to achieve is not possible with normal ble capabilities:
Apps that support background execution may be relaunched by the system to handle incoming events. If an app is terminated for any reason other than the user force quitting it, the system launches the app when one of the following events happens:
Refer to Understanding When Your App Gets Launched into the Background
The way tile works is by using the iBeacon standard (my best guess).
An iBeacon is substantially a BLE. Your app can start a Region Monitoring for an iBeacon receiving region events (enter, exit). These events would wake your app also if the user killed it. When your app is awaken by a region enter event you have 8 seconds (give or take) to execute code and react to the event. Within this time you can start a standard BLE connection to use your iBeacon as peripheral and keep your app reactive to BLE events.
Of course your peripheral must be designed to support such behaviour.

iOS advertising beacon in background

I devlope advertising data app in iOS.
My app advertising data is good in foreground.
But I want to advertising beacon data in ios background.
I set up background-peripheral setting.
and advertisingData
advertisingData = [CBAdvertisementDataLocalNameKey: localName,
CBAdvertisementDataServiceUUIDsKey: [serviceUUID]]`
that's well show foreground
when, my app stopped(home button), ios beacon scanned,
but all data not showing.
I already know in background mode, services gone `overflow' area,
but is there anything you can do without a offical way?
I wrote my master thesis about this topic. The answer is no, it is not possible to make an iOS App advertise beacon data in background.
It doesn't work with the traditional CoreLocation APIs. What you may be able to do, is to replicate the iBeacon behavior in your app while supporting background broadcast and detection, but I did not manage to make the broadcasted signal to be recognised as a beacon.
Check this answer for additional information:
https://stackoverflow.com/a/19941436/3726570

Hold XMPP connection in background mode as BLE accessory (iOS, Swift)

I'm making simple iOS messenger with XMPPFramework. So the problem is, that if i app goes into background it's disconnects from XMPP server, so the only way to store incoming messages without opening app is Push-notification (add message var into push), which is not so good way.
Also, ma app make phone acting as iBeacon to track locations of other near phones. As i know, with such capability app can stay active even in background, but can i also hold's XMPP connection while i'm in background, tracking iBeacons? Or Apple finds out and reject such app?
Thanks for help?
It is important to distinguish between an iOS app running in the background and one that has been suspended.
Yes, you can use beacon trasmissions to keep your app alive in the background. When it is alive, you can do networking events in the background including XMPP calls.
There are limits to how long a beacon detection can keep an app alive in the background.
On the receiving side, by ranging and monitoring for beacons at the same time, you can keep it alive for 10 seconds for each new beacon region that appears/disappears, and you can extend this to 180 seconds on request. It is possible to game this system by rotating the beacon transmitted every 2 minutes to ensure there is always a new entry/exit event.
On the transmitting side, iOS devices can only transmit iBeacon packets when they are in the foreground. So the best you could do is keep the receiving app alive in the background and communicating with XMPP whenever there has been another app in the foreground within beacon range (~50 meters) within the last 3 minutes.

CoreBluetooth and iBeacon: any conflicts?

I have got a chip that has a iBeacon service as well as a standard BLE service.
I would like to use the iBeacon service to trigger the app that I am developing when entering a BLE signal range.
Once active I'd like the app to scan for peripherals using CoreBluetooth and then connect to the chip.
Is this against Apple terms and conditions?
Apple has no known restrictions on this setup. In fact, this is how the RadBeacon configuration app works.
Using this technique, detecting a beacon in the background will only give your app 5 seconds of background running time, which generally is not enough time to reliably complete Bluetooth pairing and data exchange. Your best bet would be to present a local notification to the user on beacon detection, and then if the user brings the app to the foreground, do the pairing.
An alternative would be to extend background running time using a technique like described in my blog post here. That post shows how to range for beacons in the background, but the same technique will work for bluetooth communication tasks.

CoreBluetooth to detect accessory proximity (whilst app in background)

I would like to use CoreBluetooth to detect the proximity to a hardware (emitting BLE signals) when the app runs in background.
The first step is activating BLE background mode in the capabilities tab. This will allow the app to receive BLE signals also when running in background. Now, the second step would be to write the code to detect the proximity to the BLE peripheral.
Looking at the iOS developer Bluetooth guide (at page 45/46) I found:
CBCentralManagerScanOptionAllowDuplicatesKey constant as a scan option
when calling the scanForPeripheralsWithServices:options: method. When
you do, a discovery event is generated each time the central receives
an advertising packet from the peripheral. Turning off the default
behavior can be useful for certain use cases, such as initiating a
connection to a peripheral based on the peripheral’s proximity (using
the peripheral received signal strength indicator (RSSI) value). T
Is this the correct direction for this?
In terms of iOS device battery usage, is this approach less efficient than using iBeacon?
Yes, it is a valid approach to use CoreBluetooth as you describe. You can get a callback for each packet you detect in the foreground (and in the background for non-manufacturer advertisements). You can then read the RSSI as an indicator of proximity.
Whether you want to use CoreBluetooth or use iBeacons with CoreLocation, the battery usage is similar in most foreground ranging cases.
If using CoreBluetooth, you probably don't want to keep getting callbacks for every packet indefinitely in the background, because it would drain the battery faster. CoreLocation iBeacon APIs limit you to 10 seconds of ranging in the background for each wakeup event to help save battery.
If you see your app ranging for longer periods in the background using CoreBluetooth you may want to add your own logic to protect against battery drain.

Resources