Keep SignalR connected in background in Android Oreo - signalr

I used a service in my android app that check SignalR connection state every 10 seconds and if was disconnected, try to init SignalR and make it connected.
But in Android 8 some limitation added (Read more), that kill background services and also we can't call startService method to start service from BroadcastReceiver that detect device boot completed.
What's your best solution to resolve this problem for all Android versions, that is better without any dependency?

Related

get a broadcast to android app on BLE connection

A question about registering BLE notification on android:
I am developing an app that once the android device detects our beacon/ble hardware, should write something to one of the writable characteristics of that hardware.
Trying to understand, on the android app side how can I register some intent to be called when a ble connection was made to the android framework.
since a broadcast receiver registered in manifest can no longer launch my app and android background services policy was changed, this can't be done. so..
I am trying to use JobScheduler which was designed to be launched based on criteria. this can launch a JobService to do the job.
When the app is in foreground or background this seems to be working.
The thing is, I need to be notified when the app is not running (Not even in background)

ChromeOS / Chromebook exception when connecting to BLE devices (getCharacteristic)

In a small team we're developing an application that is deployed to both Android (Tablets) and ChromeOS devices. For this, we have a couple build targets such as Pixel C's, Galaxy Tabs, an Asus C302 Chromebook and a Pixelbook.
The App we're developing interfaces over BLE with a Windows 10 system that runs an application that accepts incoming BLE connections. What we perform in our App:
We perform a scan to find a device with a specific name
We connect to this device: using the Android Native BluetoothDevice class: mBluetoothDevice.connectGatt();
We request the services: using the Android Native BluetoothGatt class: mBluetoothGatt.discoverServices();
When our App is deployed to Android targets, it successfully connects to the W10 app and retrieves its services (onServicesDiscovered).
However, when the same builds of the App are ran on ChromeOS, the following exception is thrown for retrieving services:
08-17 10:46:52.750 3827-3846/com.(our namespace) D/TheApp: BleGattHandler | onServicesDiscovered() called with: gatt = [android.bluetooth.BluetoothGatt#baff2ee], status = [0]
08-17 10:46:52.751 3827-3846/com.(our namespace) W/BluetoothGatt: Unhandled exception in callback
java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothGattCharacteristic android.bluetooth.BluetoothGattService.getCharacteristic(java.util.UUID)' on a null object reference
at com.(our namespace).communication.bluetooth.lowenergy.BleGattHandler.onServicesDiscovered(BleGattHandler.java:90)
at android.bluetooth.BluetoothGatt$1.onSearchComplete(BluetoothGatt.java:237)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:103)
at android.os.Binder.execTransact(Binder.java:565)
Our conclusion is that for some reason, ChromeOS fails to retrieve the services of a BLE device. We're at a loss here and hope to hear if anyone of you knows the cause or possible resolution (we're also open to professional help)
What ChromeOS version are we using
Our most recent test (today) was on the Pixelbook with:
ChromeOS 68.0.3440.87 (from beta channel)
ChromeOS 69.0.3497.21 (from dev channel)
What we have found up till now
This ChromeOS issue, yet it is reported Fixed:
https://bugs.chromium.org/p/chromium/issues/detail?id=722987
Android app which interacts with BLE devices not working on Chromebook
Why are we not using 'normal' Bluetooth (classic)?
We're currently using a C# W10 App to connect to using the App. However, this application serves as a Stub for now and will in the near future be replaced by a low-power embedded solution (wearable product) we are developing that requires operation over BLE. We're therefore bound to use BLE.

Xamarin.iOS bluetooth connectivity on iPad locked

My BLE device uses SSL certificate on connection which is causing the app to hang when the iPad gets locked. It works fine as long as I don't lock the iPad. anyone faced similar problem?
What I tried is to disconnect the device on sleep and reconnect it on resume. It works fine when the app goes into background and comes back, the problem comes when I lock the iPad and then resume to app. Same events fire whether I lock the device or minimize it.
Can anyone tell me how Xamarin handles these 2 things?
I have enabled background modes and tried everything available on the internet but I couldn't get it working.
It starts working when I kill the app and try to reconnect it.
How do I dispose the connection with my bluetooth device properly on sleep and then start as a new?
P.S I'm using dependency services in Xamarin.Forms.

SignalR unavailable reasons

I'm developing a real time application using SignalR. Where SigalR will be hosted in an ASP.NET (VB.NET v.2010)
I have the following questions regarding SignalR availability:
What are the cases on which a client could not connect to the signalR?
Is SignalR is trusted to support Real Time Applications?
To have a static (shared) array in the hub, will it affect the performance if the array is too big?
Since the user of the client app will connect to the ASP.NET app via web-service, then is there a cases where the client app can consume the web-service and can not connect to the SignalR?
Can SignalR keep alive for long time, since my app will be working 24/7?ยด
What are the cases on which a client could not connect to the signalR?
Network failure will do it. SignalR will attempt to reconnect due to a transient failure. Or your app being down. :-)
Is SignalR is trusted to support Real Time Applications?
Yep. I'm currently working on an app that has around 3K continuously active users and we never have any widespread connectivity problems. In fact, I don't even recall seeing a support ticket related to SignalR connectivity.
To have a static (shared) array in the hub, will it affect the performance if the array is too big?
Well, pursuant to available memory, you should be fine. Be careful with threading. If you are locking to access an array that is frequently updated, watch out for lock contention.
Since the user of the client app will connect to the ASP.NET app via web-service, then is there a cases where the client app can consume the web-service and can not connect to the SignalR?
I can't envision a scenario. A proper SignalR implementation would be available if network connectivity is available.
Can SignalR keep alive for long time, since my app will be working
24/7?
Yep. SignalR will attempt to reconnect due to transient network interruptions. You can also handle events on the client for disconnect to attempt to reconnect after SignalR gives up.

How do you listen for messages while the app is running in the background?

How do you listen for firebase messages while the ios app is running in the background?
How can I check for new messages while the ios app is running in the background?
The Firebase SDK uses iOS's underlying sockets, so the library will report new messages as long as the OS keeps the socket open. This can depend on the configuration of your app. If it is configured to be able to run in the background and use the network, then your observers will continue to function just like when the app runs in the foreground. If you app is not set up as able to run in the background, then the OS typically keeps the socket open for a short time before closing it. In that case, your app will need to enter the foreground again before it can start receiving new messages.

Resources