Part of our React Native App lets users use it in the background while they use other apps.
If the user then force quits the app while our app is in the background we want to do some cleanup and send some analytics. Since we can't get the applicationWillTerminate event in React Native we need to do this cleanup in the native side.
So we were wondering if there is a way to access the Redux store in this event. Or what is the suggested way to handle this?
Related
I am building a React Native app and would like to add weekly local notifications. The notifications should include dynamic data, such as a screen time increase, which will be calculated right before the notification is sent.
When the user enables the notifications by clicking "Enable Weekly Reports", the scheduleNotificationAsync method is called, taking the title parameter as input. However, the title will change over time.
What is the best way to periodically schedule notifications with dynamic content in React Native using the expo-notifications API?
Note: The BackgroundFetch method only works when the app is in the background, not if the app has been terminated or after a device reboot.
Related Questions:
React Native - Expo notification Scheduling
I have a notification listener, and I need the app to refresh when a specific notification arrives. How do I make the screen reload/refresh in react native?
For more context, my app has two types of users, anons and friends. When I send out a friend request to an anon, and they approve, I need to the screen to refetch users so that they are removed from anon list and added to the friend list.
A potential solution would be to dispatch a user fetch in the App.js where notification listeners are, but I wonder if it's slightly easier/cleaner or even possible to just cause a screen refresh (rerender) in react native.
I have a brownfield Android application that has multiple activities, some of which are native and some of them react native.
What I wanted to know is that is there a way I can reuse the same react instance across all of my react native activities?
Right now, whenever we are creating a new activity that uses React Native, we have to initialize a new React Native instance and sync a lot of data along with rehydrating our entire redux store. This process is painfully slow and also consumes a lot of memory.
On iOS, you can reply to text messages right from the push notification without opening the app. I want to do something similar in React Native, to have the user interact with a custom UI in a push notification without opening the app. At the moment I'm using react-native-onesignal, but I haven't found a way to get this functionality with OneSignal. Does anyone know how I can approach this?
How can I detect termination of a react native app so I can do some cleanup? Currently I only care about this for Android.
You can check AppState Api , it'll tell you about app state like active, background and inactive
Without custom modifications I don't think this is possible, you can however try to trigger your react native code in the native handler for when a view gets destroyed... If possible, you should implement a waiting loop there that can be stopped when your react native cleanup is done.
PS: I did not yet try this out myself!