I'm using code-push to update my react-native app. I do not want to update it every time via App Store.
I'm using installMode ON_NEXT_RESUME, thus the update is downloaded but not installed immediately. The new content will be available the next time the app is resumed or restarted, whichever event happens first. (if the app was inactive for 10 mins)
My code is as follows:
componentDidMount() {
codePush.sync({ installMode: codePush.InstallMode.ON_NEXT_RESUME,
minimumBackgroundDuration: 60 * 10 });
}
But the problem is than the app is updated but the user doesn't know it.
Is there any way to show an notification of something like that to user after successful update?
You can use
codePush.SyncStatus.UPDATE_INSTALLED
https://github.com/Microsoft/react-native-code-push/blob/master/docs/api-js.md#codepushsync
Related
Our react-native 0.66 Android app has an AppState change handler which is called when the app goes into the background / foreground...
import {AppState} from 'react-native';
...
this.changeUnsubscribe = AppState.addEventListener('change', this.handleChange)
...
handleChange(nextAppState) { console.log(`App state changed to: ${nextAppState}`) }
Works perfectly on Android 10. However on Android 12, the change event isn't happening when the user brings up the Task Manager.
Instead the event happens when you swipe up the app in the Task Manager (to close the app).
Unfortunately that causes a problem: It seems Android 12 limits the amount of activity you can perform as the app is closing. We're trying to save user data when the app goes into the background, and it's not always managing it. Pre-Android 12 our app managed it fine.
I can't find any mention of this new behaviour in the react-native or Android docs. Any tips anyone?
Answering my own question, hope it helps others:
For react-native v0.66 on Android 12 (may be the case for other versions): The system Task Manager no longer triggers the AppState change event.
It now triggers an AppState blur event. Returning to the app triggers a focus event. The AppState currentState will continue to be active while Task Manager is in the foreground.
recently i develop flutter app that each time after validate if user subscribe to app, should download all content to user phone that user could use content event in offline mode and check what is last state of user send to back end for next time that user open app. my problem is when user subscribe and receive content for next time application does not check if some thing new add.and at the same time does not send last state of user to back end. in dev mode everything is fine but in production nothings works does any one knows what happen and, I thinks maybe it depend on server deployment but i'm not sure? could you please help me.
I modified some redux store (using redux-persist) logic in my app, and when a user update the app, at the first launch he get a crash because of inconsistency between the previous store and my new code. If the user relaunch the app everything is fine.
How can i detect that this is the first launch of an updated app version, clean the store and then render the app with new store initialization ?
I know how to clean the store, the part i struggle with is the way to know if the app just got updated and it's the very first launch. I don't want to clean at every launch.
Thanks in advance
I'm using callkeep to show an incoming call screen when a VoIP push notification is triggered. What I want to accomplish, is to ring the user for just 20 seconds. In case the user never answers, the incoming call screen should just disappear. How can I do that with callkeep?
Should it be modified in the javascript code or in the AppDelegate?
There's a solution, which is done on front end part.
First of all, run
npm i react-native-background-timer
This will help you run scheduled tasks when the app is closed.
Then, you will need to add the listener:
RNCallKeep.addEventListener("didDisplayIncomingCall", onIncomingCallDisplayed);
Which is fired when call is displayed.
And then implement it like this:
const onIncomingCallDisplayed = ({callUUID, handle, fromPushKit, payload,}) => {
BackgroundTimer.setTimeout(() => {
RNCallKeep.endAllCalls();
}, 120000);
};
Where 120000 is time in milliseconds when you want to end the call.
You could also add a backend request to notify your server that the call is rejected.
I'm working on a React Native app where I need to send recurring push notifications at specific times. So for example, the user will toggle the app to remind them to do task X every day at 12:00pm and I want the app to send a push notification at 12:00pm (when the app is in the background) to remind the user to complete task X.
For the React Native app, I'm using expo and I've read up on their documentation; however, I'm not quite sure how to handle these reminders.
a) I don't know how to monitor recurring events, i.e. how can I set up the app to know when it's 12:00pm, especially given that the app will be running in the background or potentially not running at all, and
b) I'm not sure if these push notifications should be sent locally within the app or from the app's API/server.
Ideally, I would like to use expo's push notification feature, but I'm open to any suggestions as to how to get this set up! Thanks.
a. ) You should look into node-cron or node-schedule for scheduled push notifications.
b.) It depends on the situation. If you are performing a complicated reminder, such as running a query to check if the task is completed, and sending a notification if it is not completed, then the scheduled push notifications should be sent remotely from the api/server. Else, you can use the react-native push notification to send a local scheduled notification.