I'm developing an app in Ionic/Capacitor/Vue for both iOS and Android, but now I am in need of some guidance.
The app will communicate with a satellite antenna over Bluetooth LE. I'm using https://github.com/katzer/cordova-plugin-background-mode to keep the app running even when the screen is off. However I'm not in control of the antenna firmware, and so far haven't been able to test what happens if the antenna sends some packet while the screen is off or the app is in the background. What I'm hoping would happen is that the app would act on the incoming communication, even if it's in the background.
Also, the background-mode plugin has this warning on its website:
Infinite background tasks are not official supported on most mobile operation systems and thus not compliant with public store vendors. A successful submssion isn't garanteed.
I need to have this app published on both App Store and Play Store. What other options do I have?
There are two up-to-date plugins which help running background tasks on Android:
Foreground Service: https://github.com/capawesome-team/capacitor-android-foreground-service
Battery Optimization: https://github.com/capawesome-team/capacitor-android-battery-optimization
Please note that I am the project owner.
On iOS you should only need to use the Bluetooth LE plugin without additional plugins.
Related
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
I have a security system where moving a Bluetooth LE device causes my android application to do some work. After some of the newer Android updates, I believe API 26, I could no longer get these updates if the Android device's screen was off. I was trying to think of a way around this and came up with an idea:
What if I paired the Android device and the Bluetooth device - would this allow for the message to be received when the Android screen is off?
Previously, all my BLE devices were part of a mesh, so I would regularly have the Android app check for changes in the mesh and turn the screen on to notify the user if needed. Now, because of the background execution limits introduced, I must require the Android device to have the screen on at all times, which leads to the death of display over time.
I'm not that great at programming in C, which is the language the BLE chips are programmed in, so I wanted to ask this first before spending hours just to see this NOT work. So, just to repeat the question: Will having a BLE device paired with the Android device allow a message through these restrictions when the Android screen is off?
If not - is there a way I can make this work?
Thank you for any info!
Use notifications instead of advertisements. This will deliver data instantly and works even if the screen is off. Newer versions of Android have introduced more restrictions for BLE scanning when the screen is off.
Use connectGatt with autoConnect set to true to automatically connect and reconnect in case the connection drops.
Use a Foreground Service in your app process to prevent the app process from being killed. If your app process exits, all Bluetooth connections are dropped as well.
You could use CompanionDeviceManager to gain some extra permissions.
You don't really need to be paired but it has some benefits such as faster connection setup and correctly remembering the address type (flaw in the API that this is missing).
Currently I am working on an application which has BLE peripheral, my app works as master and the BLE device works as peripheral.
The app has below mentioned use cases:
The application should connect and communicate with the BLE device even if the app is not in foreground. (app can be in background or closed)
Once the app is connected to the BLE device we need to get the data in our application and process on it.
So the basic use case which needs to be achieved is, once the BLE device is in our device's range it should connect and communicate with our app
, whereas once its out of our device's range it should stop the communication process.
All these things should work well even if our app is in background or closed state.
As per the background limitations from oreo as mentioned in this link https://developer.android.com/about/versions/oreo/background
, we can not use services to achieve this scenario.
Currently we are using foreground services to achieve the desired use case, but not sure if that is the best approach to work with.
Please let me know the best approach which can be used to achieve the above mentioned use case using the latest android api.
Note: Our app has minimum sdk version 23 and target sdk version 28
I'm actually working for a startup I'm building with two other founders. On the side I would like to develop a quick prototype to be able to deepdive into a subject I can use on my project : beacons.
Here is what I want to achieve : I want to be able to use a device as an emitter (using bluetooth, BLE, or wifi) and the other one to be able to know when it enters the first one range. I need that to be able to do indoor localization (just a check in system, not to know exactly where people are in that specific location).
I'm used to code mobile application with Ionic and I'm more a Javascript developer. I saw that there is already something which fit to my needs : Dazting which transform every device mobile as "a beacon" with either bluetooth or Wifi. Problem, I want to do it on my own but to be honest I don't really now how they manage to do that with Wifi. I know that there are some libraries to emit with BLE but what about bluetooth ?
Does it mean I'll have to code it with native code ?
This is what I want to achieve :
Coding an hybrid app (will loose less time and one app for every
platform)
Transforming the mobile device into an emitter : with bluetooth or
wifi
Be able to know the distance between a device which will emit and a
one that will receive the signal
I don't want to go with beacons : I'm not going to use macro-location and buying beacons for my project at the start is not something we would like to do.
Any ideas or suggestions on how did Datzing manage to reach that goal ?
Thanks in advance.
Datzing relies on emission of Bluetooth Classic, Bluetooth LE and WiFi packets from a mobile device that is made discoverable, either programmatically or through manual selection in settings. The unique MAC address or SSID of the device can then be used to tie the detected transmission to a registered "Beacon" on the Datzing system. Basically it just registers the unique identifier associated with a Bluetooth or WiFi transmission with the Datzing servers so they can have meaning.
Using this technology to transmit on an iOS device is severely limited due to operating system restrictions. Users essentially have to manually go to settings screens to start the emissions. Android devices are much more flexible if you have a native app granted the proper permissions.
On the detection side, iOS is also much more limited than Android due to the operating system blocking access to raw MAC addresses of bluetooth devices and preventing detecting SSIDs of WiFi access points unless the network is connected. As of Android 6.0, access to the raw MAC address is also restricted, making such a system work less well with Bluetooth on newer Android devices.
On both platforms, iOS and Android, the ability to use these techniques to the extent they are allowed by the operating system are possible with native code. Doing so with Ionic or Cordova would require cobbling together a number of plugins (if they even exist) to bridge to the native features to access WiFi SSIDs and do Bluetooth discovery and scanning. This is unlikely to be a quick protoype.
Word of caution: It is always a good idea to try out a system like Datzing before trying to reproduce it yourself, as limitations often cause technologies not to live up to the claims of the marketing materials.
I am new to beacons, but I am trying to understand the pros and cones of iBeacons for an app on iOS and Android:
I understand that on iOS:
Apps in the background can monitor for BLE/bluetooth
Apps in the background can be opened through a local notification which the user can press and thereby open the app.
But this still leaves two important use cases I am unsure about:
1)
When the app is installed, but not running at all, is it possible to have the app launched or at least a message asking to open the app on:
iOS?
Android?
2)
If the app is not installed - is it possible to prompt the user to download an app like EddyStone beacons on:
iOS?
Android?
Yes, when an app is not running, you can detect beacons and have them send notifications to a user on both iOS and Android. Tapping on the notification will bring the app to the foreground. There are a couple of platform-specific distinctions:
Android: A third party library such as the open source Android Beacon Library must be used to trigger background scanning even when the app has not been launched by the user. (Technically the app is running when doing this scanning, but only the beacon scanning parts of it.) On an Android device only, you can fully launch the app to the foreground on beacon detection instead of just sending a notification. Background detection works well with both iBeacon and Eddystone.
iOS: Background detection works much more quickly with iBeacon than Eddystone.
It is not possible to use beacons to prompt users to install your app on iOS using either iBeacon or Eddystone.
On Android, it is possible to use Google Nearby to prompt a user to install your app on newer Android 4.4+ devices. (This works with both iBeacon and Eddsystone, if you have your beacons properly configured with Google.) That said, a number of conditions must be satisfied for this to work:
Google Nearby must be enabled in Google settings
Location must be enabled
Bluetooth must be on
Google Play Services v.10.0 must be installed on the phone (earlier version 9.8 available through November 2016 had Nearby notifications disabled.) Note that most phones in China and many other countries do not have Google Play Services at all.
You must register your beacons with google and set up Nearby app intents.
Read more about the basics of Nearby here and more about using App Intents to send users to the Google Play Store to install your app here.
http://developer.radiusnetworks.com/2015/07/22/how-to-push-messages-without-an-app.html