Background event in react native application - react-native

I was wondering if there’s anything that could trigger an event in the background in react-native.
I’ve created my project with CRNA(I cannot use native code until I detach from expo and thus cannot have the android or ios folders.)
In my case, I need the data to be sent to firestore database at a particular time.
can anyone help me with this?
thanks in advance

You would need a native module to do this as expo does not support background events at this time.
Could your requirements be solved with a server function? Or do you need to send data on the device, such as latitude/longitude? The only alternative I can think of is sending the data ahead of time to a server and then have that server send the message to firestore at a particular time.

Could use a bit more information, but this is possible if use redux with redux saga, and dispatch an action from your container component whenever you need to set the data on firestore. Your saga should handle the setting of the data.

Related

React Native bridge: send data continuously from native to JS?

I have read a bunch of resources online but didn't see any similar use case. I need to send data from native (Android) to JS continuously, with the data being small sized string.
Would this (from RN tutorial)
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java).emit(eventName, data)
be the best way to do it? What if we need the message to be sent very frequently? Like every 100ms? Is there any other way to do it with better performance? How frequent can it go?
Thank you!
In react-native your javascript app is running on a different thread than you native application. I don't thinks there is a better way for sending data between the two threads than EventEmitter.
In the source code of libraries sending data frequently, EventEmitter is always used (example: react-native-sensors).

Prevent MobileFirst Platform from presenting adapter response in Native iOS App

Overtime I request something from an Adapter of MobileFirst Platform 7, I see the response on the log window on a Native iOS App.
This is consuming memory, blocking the execution of the App and annoying me :)
Is there any way yo block this ? If I want to see the response, I can use NSLog.
Thanks.
AFAIK the ability to not display responses does not exists.
Feel free to submit feature requests, though...
Besides, is it really the display of the data and not the fact that you return probably a lot of data, thus it takes it longer to arrive before it finally gets printed?

Showing shell Toast notification on receiving message

I am trying to make a chat app using XMPP protocol. The app is working fine except it doesn't show message notification when the app is in background. In Android I have used a Service for this purpose, however in Windows Phone I couldn't find anything similar to this.
I am trying Background Tasks for this, but as far as I have understood, they're made to run on prespecified trigger and I cannot add any custom trigger to it. In Android I have put my socket connection and parsing message calls in the service itself so that they can run on background too and the socket doesn't get closed even when the app is stopped.
So my question is, is there any similar way to do it in Windows Phone 8.1 (WinRT, not silverlight) or if Background Task is the only option, can you suggest a way to implement the notification functionality. I don't need the exact code, I just need a push to the right direction.
First: You cannot run a network connection in background.
Suggested way is using PushNotifications:
Either directly with a Toast Notification
Or with a PushTrigger to handle a Raw Notification, work out what to do
with it (who was it from, prepare data, etc.) and then create a ShellToast from it. Adds flexibility and improves user experience, but is quite complex.
Known downside: You have to use a server.
Only workarounds: Background-Tasks that checks for new messages about every 30 Minutes.

Can wifi / geo triggers be invoked even if the Worklight app is not running, including not in the background?

In Android, an app which is not currently running can be notified when certain event happens (like wifi scan results available, boot process completed) through Broadcast Receivers mechanism. Is this possible in anyway so that the wifi/geo triggers can be invoked even if the Worklight app is not running, including not running in the background?
Regarding wifi/connectivity changes notifying your app, that looks possible since it is a standard system event. It would likely take custom native code since you'd need to implement a broadcast receiver. And you'd need to register your receiver in your app's AndroidManifest.xml file. Take a look at http://developer.android.com/reference/android/net/ConnectivityManager.html and http://www.grokkingandroid.com/android-getting-notified-of-connectivity-changes/
Regarding geolocation triggers, it is unclear what sort of triggers you are looking for. This is all I see in the Android docs: http://developer.android.com/reference/android/location/GpsStatus.html and the standard broadcast actions at http://developer.android.com/reference/android/content/Intent.html#constants
If you are looking for something like geofencing, it would take application logic to determine when to fire events, so that means an app or service needs to be running. So although your broadcast receiver's onReceive() method can get called upon a geo event, who is going to fire that event?
Having the triggers activate when the application is not running at all (not even in background) isn't supported through the Worklight APIs.
You could try and use Worklight Android Native SDK together with cmarcelk's suggestions. Or you could use the Worklight Android triggers within a native service, together with the Broadcast Receivers mechanism so that it will run automatically on boot. You could then use an Intent to open the application from the trigger callback.

How to create a scheduled GET request and send Notifications when the app is in background?

I have a Web-Service application, i need to send scheduled GET methods to my server and if a change has happened with my incoming data i have to inform my user about the changes. When my app is in the foreground(in min thread) i fetch some data and pıpulate my tableview, my problem is, i can't realize how to create a scheduled method to the same data source(mean server) and if a new thing has been added, either my app is on bacground or not, inform user(alert) about the changes. Can anyone please share any idea-link.. Thanks in advance
This is exactly what push notifications were designed for, and are, technically the best way to solve the problem.
It does mean the task of 'checking' for new data is shifted to your server but the user is better suited as a push notification will happen, even if your app is not running.
I recommend using a system like Urban Airship.