Detect beacon when in the proximity, iOS & Android application - android

I'm building an iOS and Android application and want a user to get notified when he'll be in the proximity of a Beacon. I am looking to understand the following cases whether the user will be able to receive the notification:
If the application is in the background and the user has come into the proximity of a Beacon, will it allow the application to send him a local notification?
If the application is in the killed state and the user has come into the proximity of a Beacon, will it allow the application to send him a local notification?
Which Beacon will be best for my use case?
any help here will be appreciated.

1. Yes
2. Yes
If an application is killed, you have to make sure that on Android you run a background service that listens for beacon proximity and make sure it does not get killed by the system. On iOS side you should setup background beacon scanning with Bluetooth LE accessories usage turned on in "Compatibilities" which will not get killed by system if setup correctly.
If your Bluetooth device is NOT a Beacon and just streams some advertisement data over the air, then on Android side you should be able to setup background Bluetooth scanner, while on iOS it will not be possible to do such a thing if a Bluetooth device is not connectable (even with connectable device it will be hard).
Those services could launch local notification when beacon enters required range.
3. Any
Answers are valid if Android and iOS applications are setup correctly and Beacons are TRUE beacons and not a random Bluetooth devices that stream advertisment data.
Good luck :)

Related

Do turning bluetooth on with Android makes it a beacon?

if i turn on bluetooth in iOS it will be discovered in beacon scanner, is it the same with Android?
Or we should turn the android to be a beacon explicitly using any libraries like alt beacon?
What am trying to achieve is to get RSSI from android by ONLY enabling Bluetooth.
No. Turning on bluetooth does not make mobile devices -- neither Android nor iOS -- advertise as beacons. If you want to make either platform advertise as a beacon, you must install a custom app that is programmed to start the advertising. The Android Beacon Library has tools to do this on Android. On iOS you can use built-in CoreLocation and CoreBluetooth.
On both iOS and Android, if you turn on Bluetooth from the settings screen and leave the settings screen up, it will emit both BLE and Bluetooth Classic packets to make it discoverable by external bluetooth scanning apps. But these advertisements will absolutely not be BLE Beacon advertisements in the strict sense. It is still possible to detect these non-beacon packets with some scanning apps.
Just enabling bluetooth on either platform might make it detectable based on what the other apps are doing. There may be pre-existing apps on the phones that emit BLE beacon advertisements, BLE GATT service advertisements, or similar. However, you cannot predict whether any individual device will do this because you can't predict what apps are installed. Nor can you know what advertisements random apps will emit in a way that is predictable. If you want to be able to rely on detecting another device with BLE in a predictable way you must get an app installed on that device.

Android BLE Notification

I'm developing an android application using BLE. I've implemented all the basic operations like discovery, connection, and data transfer.
Now I was looking for BLE notifications, Is it possible to receive notification from BLE device when the application is not running (not even in background).
What I want to implement is the notification similar to GCM/FCM, we receive notifications in our app even though app is not running.
So want to check if similar notification mechanism is supported by BLE devices and Android framework.
I've searched for few hours now but didn't get any proper result.
If anyone can just tell me if it is supported or not?
Now I was looking for BLE notifications, Is is possible to receive notification from BLE device when the application is not running (not even in background).
BLE is just a communication protocol. When someone talks, someone has to listen.
What I want to implement is the notification similar to GCM/FCM, we receive notifications in our app even though app is not running. So want to check if similar notification mechanism is supported by BLE devices and Android framework.
GCM/FCM works because Google Play Services is running on the device listening for messages.
I can imagine two possible cases based on your question:
If by "receive notification" you mean a change in a Bluetooth characteristic - well your app should be running already. Only you know how to talk to the BLE device.
If you want to implement a location aware beacon type behavior with BLE you may be able to leverage the existing Google Nearby feature to achieve the desired effect.
I would say no. You need to have the app running to get Bluetooth callbacks. You should simply set up a Foreground Service in your process and that will keep the app running in the background.
If you want to receive notification event if your app is not running, you should implement Android service that continuously scan for BLE frames and ones it catch some frame that is met some parameters (for example for iBeacon it will be specific Major and Minor values; for Eddystone URL -- some specific URL etc.) -- just send intend to start your application.

Is it possible android/ios Bluetooth block/reject connection request under discoverable mode programmatically?

I am writing a android/ios application that detect/search another phone that turned on Bluetooth and get those name and mac address for further functions development. The application will run as background service that keep scanning the Bluetooth device.
Problems:
For Android, the phone Bluetooth needs to turn into discoverable mode that can let another phone to scan/detect and get the name and mac address. So, I am worry about that phone user keep requesting to another phone causing disturbance because the connection pair request can let the phone popup a confirm dialog box . Is it possible to block/reject the connection request under discoverable mode programmatically? Phone can scan bluetooth device and can get the information but can not request connection while the application is running.
For iOs, there is the same problem, but there is another question that i want to ask. Can Bluetooth keep scanning into background like android background service?
Turn off the screen of android devices that the Bluetooth signal still scannable. But iOs devices can not. Is it possible to let iOs Bluetooth device still be scannable when the screen off.
Thank you very much!
You can scan for Bluetooth devices in background (even when device is locked) as long as you add that background capability to your app. Simply start scanning when your app is launched, and don't stop.
However, this uses a significant amount of battery power (scans every 20ms), and even more if there are actual Bluetooth devices nearby (because scan response may be requested).
Instead, take a look at the Region Monitoring and iBeacon functionality in the CoreLocation classes. That is meant for power efficient discovery of BLE beacons.
You will not be able to get the MAC addresses on iOS. You will be getting UUIDs.
If the user force kills the app, background scanning stops.

Beacon Notification when the app is not running on Android

I am aware if it is possible to wake up an app when the user is close it a beacon. It know it is possible to do it on iOS. I have not found a clear solution on the web. Do you know if it is possible?
Yes, it is possible with the open source Android Beacon Library. It works by starting a low-power background beacon scanning service for your app when the phone boots, or when it is connected/disconnected from power.
Details about how you set this up, how it works, and its limitations are available here.

Find already paired bluetooth devices automatically, when they are in range

I am no Bluetooth specialist and wondering what possibilities are available to find already paired Bluetooth devices automatically when they are range of each other.
Background:
In our case an Android application needs to connect to a dedicated accessory via Bluetooth (Rfcomm). Both devices are known to each other (they are paired). The Android application registers a broadcast receiver. During the startup of the application, the app initiates a discovery to find the dedicated accessory. If the accessory is in range everything works great.
Problem:
The user starts the application outside the range of the dedicated accessory. The Android application tries to discover the accessory without success. Then the user goes into the range of the Bluetooth accessory. The broadcast receiver won’t get notified about the accessory that is in range now.
Similar Thread / Possible Solutions
Similar questions were already asked on stackoverflow (e.g. autoconnect to bluetooth device when in range).
But continuously trying to discover Bluetooth devices in range isn't what I am looking for because this would cause too much battery drain of the Android device.
Another solution would be to try to connect to the paired device in the onResume method of the Activity. This would work but has the disadvantage that the application can’t run in the background. So the user had to bring the application at least once to the foreground to initiate the connection.
A third idea I thought about is to implement a server socket into the Android application too. When the android application is started and the discovery finished without success, the Android application could create server socket and to listen to incoming notifications of the accessory. This would help in some scenarios (e.g. the user starts his application, approaches the accessory, activates the accessory and the accessory notifies the application on startup that it is in range now). But this is still no 100% solution because both devices can start outside the range of each other. Also it would be mandatory to implement additional functionality (Bluetooth server socket in the Android device…).
So I am wondering if better solutions exist. I am looking for a solution where no additional ServerSockets are required and I always get the notification that the two already paired devices are in range of each other :-)
Thanks for any help!
After connecting the device for the first time, keep the mac address in a local list.
On disconnect, use connectGatt with autoconnect set to true to automatically re-connect when you are in range.
Not a full solution, but maybe it's sufficient for your app to poll the accesory's presence whenever the screen is turned on? In that case, this may be helpful: Start Activity on wake up/sleep in Android

Categories

Resources