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.
Related
I have found what seems to be a bug on Android. I have not tested it on IOS.
updateProfilePhoto() is a redux thunk that just sends a PUT request to my node server.
The problem is this, I can upload an image to my node server using fetch. The image is received and saved successfully on the server. If I wait for about 1 second and the upload another image, it goes through successfully. However, if I upload an image and then upload another immediately after the first one goes through, I get the error 'Network request failed' and the second image will not be received on the server.
It seems to me that I cannot constantly upload images back to back really quickly, one will go through, the next one will fail and the next will go through... and so on.
I am testing on an Android Emulator. API level 30. I have not tested on a real device yet, I will try that when I'm able to.
The error happens for the built-in fetch() and XMLHttpRequest. Both behave the same. On XMLHttpRequest I can check the progress and it says 100% and then fails with xhr.status equal to 0.
I need a sure fire way to upload an image to my server without it failing for no reason. I can add a delay of something like 500ms between uploads and show the user that it's loading but that's a silly way to resolve the issue. I can't find out why the upload fails on the second try.
const onSelectProfileImage = (pickerResponse: ImagePickerResponse) =>
{
const uri = pickerResponse?.assets && pickerResponse.assets[0].uri;
const name = pickerResponse?.assets && pickerResponse.assets[0].fileName;
const type = pickerResponse?.assets && pickerResponse.assets[0].type;
if(uri)
{
const photo = new FormData();
photo.append('photo', {name,type,uri});
dispatch(updateProfilePhoto({photo, uri, user_id: id, headers: {...headers,"content-type": "multipart/form-data"}}))
}
}
Im building a react native App using expo. Im able to send notifications daily like so
Notifications.scheduleNotificationAsync({
content: {
title: "Reminder",
body: "lorem ipsum",
},
trigger: {
hour: 12,
minute: 30,
repeats: true,
},
});
My goal is to send a reminder to the user every day at the same time. I want to send a different reminder message each day say from a database or an array of messages, how do I go about doing that? been stuck for a while
This method to schedule notification does not allow specific code to run when the notification is fired. If you have the message you want to send for the next time, you can fetch that data the moment you schedule the notification. Otherwise, I think you should do that on your server-side application using expo's push API with some kind of cron job.
Another alternative could be the BackgroundFetch api, but you'll need to code some logic to re-schedule the task to fetch the data and send the notification.
I'm really confused on how notification listener works in expo, especially for a killed app, I read the doc and I knew that addNotificationResponseReceivedListener listener use when the app is ( in background or killed). I need to know how this listener work and when I unsubscribe the listener does it keep listening?
this callback is called after the user taps on the notification and the App open. you will receive an object with the push notification info (like title, message and extra data) and from there you can decide if you will redirect the user somewhere or just resume the app flow.
If the app is not subscribed (if you didn't generate the token for push notification) you will not receive the notifications.
If you just didn't create the callback responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {..... your app will show the notifications anyway (normally you just use the callback when you want to do some action with the notification info)
Hope this info helps.
I am building a messaging app in react-native.
I have a problem where if the user is sending a message, then puts the app into the background before my redux (thunk) action containing all the network logic finishes, the message doesn't get created on the backend. However, I am still seeing the SUCCESS action come back from the action.
Does anyone know why this is happening? Thank you!
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