Is there any way to execute something in react-native when app is closed? - react-native

I want to develop an app which notifies user whether it rains or not when they're out.
For that, I determined to utilize push notification service.
Therefore, I need to execute something in particular time (e.g., sending request to API server) when app is closed.
Are there any modules or packages in react-native?
Thanks in advance!

Related

Maintaining AWS Datastore subscription when app is closed

This may be a general question, but I've only been able to find bits of an answer online.
I am using React Native and AWS Datastore to create a chat app that receives real-time updates through subscriptions.
What I would really like, is if the app could update the messages while in the background so that when a user opens the app the messages are already there. Is this possible? It seems from other forums that it is possible to keep a datastore subscription open when an app is closed, but I have not been able to make it work? Is IOS forcing the web-socket to close?
What is the best way to get something like this working?

Expo push notification service

Im trying to send push notification using expo notification service, can anyone give the code for it, how to get the tokens and all the other standard stuff, I have been trying to read the documentation but it is really confusing. The app is already on test flight, Also I don't want to eject.
I don't mind using Firebase, but the app doesn't have a user login pages. I don't mind any other method too.
Thanks for the help

How to Send Push Notification to Xamarin Android app?

I need to implement push notification to our Android App using Xamarin. Here is the process. We have web version which used by the Manager. The Manager creates and assign job to the driver. The App version is used by the Driver where it shows the list of jobs and processes of job until its complete. So, when the Manager assigned the Job to the Driver in the Web version, it will then notified to the Driver in the App version that "new job is assigned". Basically, both the web and app uses same database then we created an api(REST API in MVC C#) to connect and get data from the db to be used in the mobile app.
Can someone recommend to me which Push notification plugin(a plugin or nuget) should I use to do this? Currently, I have set up Push Notifications through App center & Firebase but not sure how this work.
Thank you.
I need to implement push notification to our Android App using Xamarin.
I would suggest you use Firebase for mobile push notifications for Android as it is a product by Google, and was made for mobile applications. For push notifications, you will be using Firebase Cloud Messaging also known as FCM. See to it that you are well versed on how it works before you start coding anything read the documents it answers most of your questions there itself.
The Manager creates and assign job to the driver. The App version is used by the Driver where it shows the list of jobs and processes of a job until its complete. So, when the Manager assigned the Job to the Driver in the Web version, it will then notified to the Driver in the App version that "new job is assigned". Basically, both the web and app use the same database then we created an API(REST API in MVC C#) to connect and get data from the DB to be used in the mobile app.
For this, you will have to check on how to work with Firebase using Rest-API. Once you configure the Rest-API and then apply your business logic to it things will be quite easier than you might have imagined.
Can someone recommend to me which Push notification plugin(a plugin or NuGet) should I use to do this?
My recommendation is quite simple, Do not use any sort of a firebase push notifications plugin!. I have had a very bad past with plugins and ever since then I never recommend fellow developers to use plugins until it is a well-maintained one. I would rather ask you to simply configure Firebase on the basis of the guides that are available online. Like the following Xamarin.Android guide for FCM. It is detailed contains everything that you are looking for and what else I would suggest is you check firebase related answers on SO and you will find that almost everything that is not available in docs is covered around here and in detail. Like the following:
How to handle Firebase Notification i.e. Notification Messages and Data Messages
Push Notification in android with firebase get token
How to send device to device messages using Firebase Cloud Messaging?
Receive push notifications on one android app from two Firebase projects

Using Redis pub/sub as a message queue in Rails and Node.js for Async

I have a Rails app that sends requests to a Node.js app. The node.js app processes the requests and returns to the Rails app.
This is all done synchronously in the Rails app (the app blocks until Node.js returns). However, what I intend to do is make this non-blocking.
I want the Rails app to send a request to the Node.js app and only when the Node.js app returns, the Rails app shows the information to the user via UI (without the request being blocked).
This is the first time I need to do something like this and I'm not being able to know how. I was thinking that if I put the request in a queue (maybe redis pub sub) I could retrieve it using Node.js, process and return again. Would this work?
Also, how do I know which user made the request (I have to return the information processed by the node.js app to him)?
Thank you
To know which user made the request, pass in the user ID as an argument. If you have no User Id the other option to do this is via IPs but that will get complicated fast.
But what you described sounds like it would work.
If this is your first time, may I suggest looking into this screencast: http://railscasts.com/episodes/271-resque

On a Mac how to determine a user logout is occuring

I am very new to the Mac platform and Objective-C in general and in my application I would like to know how to determine that a user is logging out and perform some actions prior to this. Any info or pointers for this?
The official way to put the hook at logging in / logging out is described in these Apple documents Customizing Login and Logout and Tech Note 2228. But I'm afraid that the log-out hook was no longer directly supported.
So, the second best way is to run a headless Cocoa app, and receive a notification from the system using NSWorkspace, see the document and the list of available notifications.
To make a headless Cocoa app, you need to set an entry in its Info.plist called LSUIElement, see here. By setting LSUIElement to be yes, the app don't appear in the dock, but perform various operation in the background.
Take a look at Receiving Workspace Notifications in this Workspace Services document.
NSWorkspaceWillPowerOffNotification
Posted when the user has requested a
logout or that the machine be powered
off.