Beacon Notification when the app is not running on Android - 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.

Related

Android: how to execute service when nearby found some ble device

Right now I'm developing client application for Android that works with physical locks with our controllers. User can open lock via Bluetooth using this application (connection -> secure session creation -> sending some user key).
All works fine except one feature: opening lock when Android device screen is off.
I am using following approach:
Foreground service that periodically scans for nearby BLE devices and when scan is successful (nearby lock device found using BLE filters), application tries to connect and send lock key to lock device.
So, there are two problems:
Android kills foreground service in few minutes after screen off. After setting ignore battery optimization it works ok, however I can't find universal way to navigate user to those settings (because those settings are vendor specific, see https://dontkillmyapp.com/ and android open battery settings programically).
Background limits for BLE scanning are tricky.
I know one application that achieved same thing without foreground service: https://play.google.com/store/apps/details?id=eu.hoermann.ast.bluesecur, this application seems to work good in background without user interaction with battery usage optimization menu.
So, question is:
what is the best way to trigger background process (device screen is turned off) when nearby suitable BLE device available?
Your requirements perfectly describe the scenario of a companion app. Disadvantage: it is only available from Android 12 (API level 31) onwards.
I think you shoul add a wake lock with the service:
https://developer.android.com/training/scheduling/wakelock
https://developer.android.com/training/scheduling/wakelock#cpu

How can I monitor the presence of a Danalock, using bluetooth?

I have a Danalock V3 Smart Lock. It's working as advertised, but I want my own Android application to detect whenever I come in-range of this device. So my application needs to be "constantly aware" of whether the device is in-range or not. My question is: is this feasible? If yes, how?
As far as I can tell, the device is not bonded to the phone. If I iterate through the list of bonded devices, it doesn't show:
// example code
for (dev in btAdapter.bondedDevices) {
val string = "${dev.name}: ${dev.address}"
println(string) // <-- All my bonded devices are listed, not the Danalock device
}
The device is managed through Danalocks own proprietary app (as mentioned this is working). But it is a Bluetooth device, so I figured I should be able to detect it's presence in my application, somehow.
This is a bit tricky because theoretically, it should be doable. As Michael Kotzjan said, as long as you know the name of your device (e.g. using nRF Connect), you can continuously scan for this name in the background mode and then as soon as you detect it, you can get a notification in your Android app. The whole BLE beacon technology works like this so it's certainly doable.
Practically, you will be facing a few challenges when it comes to BLE background mode. Since Android P, the OS has an adaptive battery optimisation feature that might kill off some apps in the background. There are a few ways around this but it will not be completely straight-forward. Have a look at the links below which cover the subject in more detail:-
Beacon scanning in background - Android O
Is it possible to share data between Android devices when screen is off
The Ultimate Guide to Android BLE Development (specifically check "Staying connected in the background")
Background scanning on Android 8+
Background BLE scan in doze mode on Android devices

Detect beacon when in the proximity, iOS & Android application

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 :)

Monitoring beacons in Android oreo after app is killed

I'm making an app that executes some actions after a device detects a beacon while monitoring for beacons after app is killed.
I am currently using altbeacon for detecting beacons on android. It works fine on stock android phones but on a few devices like OnePlus i need to run a foreground service to detect beacons which results in a notification which indeed looks a bad user experience.
In a few devices like xiaomi, I need to enable a few permissions, which differs from manufacturer to manufacturer, thus making it nearly impossible to redirect users to those settings to enable those permissions.
Could anyone please provide a workaround?
Currently I am monitoring beacons during app kill and once detected I range beacons in order to get the uuid, major and minor since I need to differentiate between a huge number of beacons.

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.

Categories

Resources