Execute code at specific time in react native - react-native

I want to execute some function of my react native app at certain times, no matter if the app is opened or in background.
For example, execute the function at monday 3:00pm and wednesday 5:00pm
Is it possible to achieve this? Sorry if the question is noob. The alternative is to send a request from server side, but I want to know if is possible from the app side.
Thanks

Currently there is totally no support for background tasks, only for Android bit it is still limited: https://facebook.github.io/react-native/blog/2016/10/25/0-36-headless-js-the-keyboard-api-and-more.html
There is also limitation in React Native, when the app is in the background the js bridge stops getting messages.

Related

Push notification in background with React Native CLI

I want to ask something regarding my final year project. I am developing a medication reminder and storing these data on the image below on async storage. So basically I want to run a notification in the background and notify the user based on the given time on the image below. So I am figuring out what libraries I should use to achieve this. Are there any libraries that I can use in order to accomplish this? Asking for suggestions.

Local notifications fire at 3 times a day on particulate time in react native

I am using push notifications but my requirement is that it will show push notification automatically at 4:00pm, 10:00am but I didn't found any good package for react native so if any body have experience with local notification share with me.
https://github.com/zo0r/react-native-push-notification
u can try scheduled notifications for that.

Website replicating in React Native, WebView vs code, notifications needed

first time asking here as i am looking for some guidance before i start coding.
I have been developing websites mostly in PHP/MySQL/Jquery for years. As I was requested to port a website to an app, I selected React Native in order not to learn 2 different languages for IOS-Android.
I subscribed to some react native lessons, as I found it very clear and fun to follow, and it indeed is.
But here I am finding that to replicate the website is a truly difficult task for me. A temporary version exists at https://app.thallo.care/app.php?language=en (view on mobile if you like). There are many fixed positioned things and floating menus that i cannot easily program on react native.
I tried webview, it works wonderfully, but i am not positive i will be able to implement notifications the way i want to, or custom app styling with inject javascript i am unsure it will work.
The only app difference comparing to the desktop version, is that the user will receive notifications. The website will have a calendar where he will add events, and i need to send notifications to the user device on the event datetime that he has set.
Now the question... Should i use webview and manage notifications on a third party app like amazon SNS or anything else, will i get per-user notifications on events with webview? (I dont need to open a specific page on the app, but it would be nice). Or should i insist on react native coding and try to replicate as much as possible, to be able to have proper notifications? Reminder - the events won't be sent by the app. they are stored in MySQL and should be stored on some other service as well (that i dont know of yet). I don't know also if the webview can handle the website programmed login-logout with $_SESSION php parameters.
I would really appreciate some guidance.
Thanks in advance,

How can i perform task even if the app is closed in React Native

I want to perform some task if the device is back online. I have tried with Broadcast receiver but its working perfectly when the app is running and the app is moved to background. but its not working when the app is closed :(.
please find the below code which i have tried..
import {DeviceEventEmitter,Platform} from 'react-native';
const func=(map)=>{
console.log("connection changed")
}
DeviceEventEmitter.addListener('GReferrerBroadcastReceiver', func);
Can anyone propose a solution for how to perform some task if the app is closed. I found Job scheduler in native android but how can i connect to React Native???
a help will be really appreciable :) ......
This library implement's background tasks. It's implementation is in JS and pretty easy to use: https://github.com/Rapsssito/react-native-background-actions
React-native-background-action works pretty well refer documentation from officially website but if u are looking for user tracking after start click then it fail after 10-15 minutes on phone lock...

Using Expo React Native, is there any way to run a stopwatch / timer in the background?

Problem
I've created a simple stopwatch app using Expo for React Native. When I leave the app (click the home button on iPhone), and return to the app, the stopwatch starts back up from the time when I left. For example, if the stopwatch is at 3 seconds and I leave the app for 5 seconds, when I return it is still at 3 seconds rather than 8.
Question
Using Expo, is there any way to run the stopwatch in the background? If yes, how? If no, what is the best workaround?
Resources
I've found similar questions that are dated, but I'm looking for something recent. Some of the resources mentioned in the other answers are the following:
https://docs.expo.io/versions/v35.0.0/sdk/background-fetch/
https://github.com/ocetnik/react-native-background-timer
It sounds like your best bet is to note the start time and persist it, e.g. using Expo's AsyncStorage. Then you can just display the time elapsed since this stored start time.