Is it possible to beacon with iOS in a background service? - ios

Based on this documentation I understand that iOS devices can function as bluetooth beacons.
The documentation states that apps must be in the foreground for the beacon to work.
We need the beaconing to work when the app is not in the foreground. Could we solve this by using a service (similar to Android)?

Sorry, but you simply cannot transmit standard beacon formats like iBeacon, AltBeacon or Eddystone when an app is in the background on iOS.
Apple prohibits this because there is limited ability to advertise on bluetooth, and not all apps would be able to do this at the same time. Instead, Apple uses a proprietary technique that allows background apps to advertise Bluetooth services in the background. This proprietary technique is not compatible with the above bluetooth beacon transmission formats.
That said, a creative project has found a way to harness Apple's proprietary background advertising technique to allow you to use a custom beacon advertising format that does work in the background on iOS. The main disadvantage is that support is limited to receiving the advertisement on other iOS devices.
The project that lets you do this is also called AltBeacon (but should not be confused with the open source AltBeacon format described above) You can read more about it here: https://github.com/Decemberlabs/AltBeacon

Related

altbeacon-IOS, Only the ibeacon is not being scanned

enter image description here
I used swiftUI, and it was confirmed that the header bridge was also working properly.
As you can see in the image, the altbeacon is scanning fine,
but not the ibeacon.
I set the layout like this
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25")
, is there any problem? please check.
I tried changing the layout like this, but it didn't work.
setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")
The OP has set up beacon scanning on iOS using the AltBeacon iOS Beacon Tools
The above tools help iOS scan and decode Eddystone, AltBeacon and other BLE beacon formats using iOS CoreBluetooth APIs under the hood.
However, the above tools cannot detect iBeacon because iOS blocks the underlying CoreBluetooth APIs from getting scan results for iBeacon advertisements. In order to detect iBeacon you must use CoreLocation APIs alongside what you are already doing. While this is duplicative, unfortunately Apple requires this duplication by sandboxing iBeacon from other BLE advertisements.

CoreBluetooth advertising in background on iOS 10

First: I have an iPad Air 2, and an iPhone 7. For further reading we estimate that the app is active and open on iPad and in background mode on iPhone. The app is exactly the same, even with same Bluetooth Service UUIDs and same DataLocalNameKey.
I want to write an app that can advertise a bluetooth service in background and is able to discover this service (optimal in background too). As I already read I can't use apples beacon technology cause there it's only possible to get scanning/notified by beacons in near in background (I tested this, works fine) but not to advertise. So I started to use CoreBluetooth as described in the mentioned SO answer cause there it's possible to advertise in background.
My app calls didDiscoverPeripheral method in CBCentralManagerDelegate on the iPhone (app in background), so it detected the iPad. The isAdvertising property of CBPeripheralManager on iPhone is true. But didDiscoverPeripheral is not called on iPad. I'm a little bit confused. One option is my iPad is not able to detect the iPhone anymore for some reasons or my iPhone is lying and it's not advertising.
So i thought I'm just a little bit of dumb and googled for "CoreBluetooth debug apps". I found Vicinity and AltBeacon. And with both apps the behavior is the same! If you background (press home/sleep button) the advertising app, the browsing app is not able to discover it anymore. If you open the backgrounded the app it will instant discover it. Both apps mention that its possible with them to broadcast in background.
Am I doing something wrong; is this behavior expected? Did I misunderstood the framework? Can you confirm this behavior?
To confirm this, the fastest way is to install Vicinity on two devices (you have to add the NSBluetoothPeripheralUsageDescription key to Info.plist) set one device to broadcast and press the home button.
This isn't anything specific to iOS 10 -- it's always been this way on iOS. On iOS, apps simply cannot send out standard Bluetooth LE advertisements when they are in the background. They have to be in the foreground to do this.
That said, there is limited support in iOS for apps advertising GATT Services in the background. This uses a proprietary technique that only works with other iOS devices that are looking for those services. (Because it uses a non-standard proprietary scheme, the same technique won't work for beacon advertisements, for example.)
Here's how Apple describes it:
...you should be aware that advertising while your app is in the background operates differently than when your app is in the foreground. In particular, when your app is advertising while in the background:
The CBAdvertisementDataLocalNameKey advertisement key is ignored, and the local name of peripheral is not advertised.
All service UUIDs contained in the value of the CBAdvertisementDataServiceUUIDsKey advertisement key are placed in a special “overflow” area; they can be discovered only by an iOS device that is explicitly scanning for them.
If all apps that are advertising are in the background, the frequency at which your peripheral device sends advertising packets may decrease.
Read more here: https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html
it was a bug in ios 10.0.(1) and partially fixed in ios 10.1
src: https://forums.developer.apple.com/thread/51309

watch OS 2 beacon monitoring and ranging

has anybody found any information about interacting (ranging and monitoring) with Beacons in native Watch OS 2 applications?
I would like to give the user the possibility to range one in an home environment without having the phone in their pocket.
I can't find any docs anywhere and I am wondering if it's actually feasible - and obviously if there is any kind of example around.
Thanks
Core Location on watchOS is stripped of all the iBeacon functionality. There are no startRangingBeaconsInRegion: and startMonitoringForRegion: methods, as can be seen in the CLLocationManager reference documentation:
https://developer.apple.com/library/watchos/documentation/CoreLocation/Reference/CLLocationManager_Class/
The only option for now is to do the ranging/monitoring on the iPhone, and pass the results to the Watch app via the Watch Connectivity Framework.
UPDATE for watchOS 4: still no iBeacon in Core Location, but there's now Core Bluetooth available for the watchOS apps, which means your app can detect non-iBeacon packets, such as Eddystone, or Estimote's Nearable/Telemetry.
Only if your app is in the foreground or has execution time though. The latter meaning that, for example, if your app is already running in the background because you're using the new "location updates" background mode for turn-by-turn navigation, or you're tracking workouts in the background, then you can at the same time scan for beacons. In and on itself, detecting Bluetooth beacons won't keep your app alive in the background, it will get suspended.
directly use watch to monitor/ranging with watchOS is prohibited by Apple (it detailed in developer document). It mean you can not turn bluetooth on watch and start monitoring directly! But there're another way, you can integrate app with watchOS, I gave a tried before with our app and it work pretty good. We're using Estimote, you can refer right here: Estimote Watch SDK Integration
It can be transport notification from iOS device to watch. They provide several helpers support that. Good luck!

iBeacon transmission when app is closed?

We would like to use some configuration of the iBeacon , where the user's iPhone will advertise its services, but when the app is closed.
So when a user come across a hardware beacon, it will recognise the user's iPhone(as a beacon) without opening the app, and even connect to it .
I could find here many opinions about that, but i wonder if there are any news with the iOS8 ,and if there is a clear answer for that from Apple ?
A couple of points:
Bluetooth beacons, iBeacons included, are transmit only. They don't see or "recognize" other beacons or phones. The statement "when a user come across a hardware beacon, it will recognise the user's iPhone(as a beacon)" is not possible with the technology regardless of whether the app on the phone is in the foreground or the background.
iBeacons are supported on iOS devices with version 7.x and 8.x of the operating system. On all these versions, however, beacon transmission from the iOS device is only supported when the app is in the foreground. See here for details.

Is there work background services for Bluetooth low energy (BLE) on iOS?

I would like do coding in ios with Bluetooth low energy(BLE). i wanting to show notification of new BLE device while app background. is possible do it? I bought BLE Device from sensor tag site.
Yes, it is possible both in central and peripheral mode. You should declare the necessary permissions in your Info.plist and then you can search for one specific service in the background with the standard method scanForPeripheralsWithServices:options: of CBCentralManager Start with reading the docs of Apple.

Resources