Keep react-native application alive on android - react-native

I work on a mobile application and use MQTT (javascript paho client) for push notification. But after user or android close application ,MQTT socket has been disconnected and cannot receive notifications. So, I need to make a service to keep socket alive. How can I make a service by react-native?

I am using react-native-background-job for a similar use case. This library allows you to run a background job that will run periodically, but for this use case the important feature is that if you pass a alwaysRunning parameter when scheduling the job, the app will keep running in the background even if the user closes it.

Related

Is it possible to receive MT4 alerts in code-readable form (E.g. webhook, API call, file etc) instead of as a push notification?

I'll be using a 3rd party MT4 EA or Indicator which can send push notifications or display an alert on the MT4 desktop screen. Is there a way to access these alerts somehow in code that I have running on a standard web server (for example by my code somehow receiving the push notification instead of my phone), or alternatively running e.g. in Python or whatever on the same VPS (or physical PC) that I have MT4 terminal running on, and reading the filesystem (if alerts are written there?) or communicating with the MT$ process somehow?
Thanks

How to always connect to socket.io even when shutdown or exit the application to be able to receive notifications from calls or messages(React Native)

I'm having a problem with react native
my app can let you video call each other using webRTC and socket.io, the technologies i use are WebRTC, React Native, Socket.io , socket.io-client, react-native-webrtc
Basically the way my app works is when you open the app you automatically connect to socket.io to listen and make calls but when I turn off the phone screen or exit the app I can't hear and receive calls can call again because at that time the socket has automatically disconnected.
I want my application can still work properly even if I exit the application my application can still receive notifications of incoming calls from another person, can say I want my application Works like Messenger App
My current workaround is to find a way for each user's socket to always be connected to listen for incoming calls from others.
Has anyone encountered this problem or have a solution for this please let me know, I really appreciate it
Thank you guys, Have a nice day <3
Move your socket to the Background service and then you can add the socket events in the service.
Note: This will increase your battery consumption.

How does apps like Whatsapp or telegram listen to the incoming call/message events on Android?

I built a VoIP calling app which maintains a persistent connection with the server to listen to any incoming calls. I implemented a background service to do this.
But since Oreo, this running code is now broken because of the introduction of Background Execution Limits
After looking into forums, I found that some people are suggesting
Convert Service to JobService and let android schedule it
Doing so, my app won't be able to receive calls when it is stopped
Run your operations in foreground services
It is annoying for some users to see a constant notification in the notification bar. So these above-mentioned options aren't working for me to fix my code for Oreo.
How does WhatsApp get the incoming (VOIP) call in Android (Oreo onwards) working around the Background Execution Limits?
(Sticky) foreground services are not affected by the restrictions. So you could use one those as replacement for background services on Oreo.
But foreground services have two disadvantages: They are less likely killed by the system in order to reclaim resources compared to background services, and hence affects the Android system's self-healing capability. And they require you to display a permanent notification. But Users are able to suppress the notification, somewhat mitigating this disadvantage.
I am assuming that you are using SIP to establish the connection and initiate calls. Without a service constantly re-sending REGISTERs, the app doesn't receive INVITEs when the server sends them.
A workaround for this problem is what is called the "push notification strategy". It works as follows, when the server sends a INVITE, it also sends an FCM notification to your app, This wakes up your app which then sends a REGISTER to your server, which in return forks the call to your app. Here is a video that better explains this strategy
There are two options:
use platform push services (APNS or FCM)
maintain persistent socket connection and exclude application from battery optimisations.

Check if process is running with VB.NET (Compact Framework 2.0)

I am working on an (console) application, which should be executed on startup and keeps running all the time in the background (executing something every 30 minutes).
How can I, in another (device) application, check if my console application is running (and start it if its not)?I am using VB.NET CF 2.0 and everything is being deployed on a device running WM 6.5
All the code examples I found where only available on the "standard" .NET.
There are several ways your "monitoring" app could work (and certainly more than I list here).
Use a named mutex (you'll have to P/Invoke it). The monitored app would create and hold it, and the monitoring app would periodically check to make sure it's held. If it's not held, the monitored app is no longer running.
Use the Toolhelp APIs. Have the monitoring app use the Toolhelp APIs to periodically enumerate the running processes. If the monitored app is not in the process list, it is not running.
Use a named event. The monitored app would have a background thread that periodically sets a named (watchdog) event. The monitoring app would wait on that event and if it fails to get the event in a certain time bound, the other app is either not running or has locked up.
Use a socket. Have the monitored app open a socket and listen on it. The monitor app would send a "ping" periodically to the monitored app. The monitored app would respond to the ping with an ack. If the monitoring app doesn't get an ack, the monitored app is either not running or is locked up
Use a window handle. The monitor app periodically P/Invokes GetWindow of FindWindow to find an always-present window in the monitored app - often by Form text. If the monitoring app can't find the Window, the monitored app is not running.

iOS Inter App Communication in Background

There is a platform application which connects to the remote server and stores required information in its local repository, that is in CoreData. I want to develop my application over this platform app. Since it is not possible to access its local storage, I have to communicate with it somehow. I am able to send/receive data using URL Schemes; however it's frustrating for user to switch between apps constantly.
Is it possible to communicate with another application via URL Schemes (or any other way) without bringing it to foreground?
With few exceptions, such as receiving CoreLocation data in the background or being notified to wake up by a local notification, it is not possible in iOS for an application to "run in the background"
This is a pretty common query on Stack Overflow, the official iOS reply can be found here
There are SO articles here and here.
Background data exchange is however not going to be a thing as there are restrictions on background app rules (so the URL transfer is going to foreground your second app)