react-native-voip-call
react-native-voip-call copied to clipboard
Hot to handle Reject Event
I have a little issue, I want to do an API call to update the call status in DB if the user rejects the call. Is there any listener or workaround to perform this action?
Thanks
You have to fork and edit this package yourself.. In android i saw reject call button Intent being sent to a Broadcast Receiver, not to main activity. So my solution on android is registering headless js task in index.android.js. and from Broadcast receiver in react-native-voip-call. I start a Headless service, everytime reject call is pressed. it will send to js side (in background without open the app), from there i can do task like update db, send reject event...
Can you please show some code so that can get idea for implementing your solution. Thanks
You can check my fork: https://github.com/ajith-ab/react-native-voip-call/compare/master...hoangtu92:react-native-voip-call:master
And here is my JS headless
`
export const lds_bg = async (taskData) => {
console.log("Task data", taskData)
switch(taskData.action){
case "callDismiss":
console.log('End call headless', taskData);
RNVoipCall.endAllCalls();
RNVoipCall.stopRingtune();
DeviceEventEmitter.emit("lds.end_call", taskData);
break;
default:
RNVoipCall.getInitialNotificationActions().then(data=>{
console.log("getInitialNotificationActions", data);
switch(data.action){
case "fullScreenIntent":
case "contentTap":
RNVoipCall.endAllCalls();
navigate("Modal", {screen: "IncomingCallScreen", params: data})
break;
case "callAnswer":
DeviceEventEmitter.emit("lds.accept_call", data);
navigate('Modal', {
screen: 'VideoCall',
params: {headLess: false, isVideo: false, remote_user_uid: data.callerId},
});
break;
case "missedCallTape":
break;
}
}).catch(e=>console.log(e));
break;
}
};
`
Thanks for the reply. can you please tell where i need to put this code in index.js right?
On Thu, Mar 23, 2023 at 9:49 AM hoangtu92 @.***> wrote:
You can check my fork: master...hoangtu92:react-native-voip-call:master https://github.com/ajith-ab/react-native-voip-call/compare/master...hoangtu92:react-native-voip-call:master
And here is my JS headless `export const lds_bg = async (taskData) => { // any background logic here // .....
console.log("Task data", taskData)
switch(taskData.action){ case "callDismiss": console.log('End call headless', taskData); RNVoipCall.endAllCalls(); RNVoipCall.stopRingtune(); DeviceEventEmitter.emit("lds.end_call", taskData); break; default: RNVoipCall.getInitialNotificationActions().then(data=>{ console.log("getInitialNotificationActions", data);
switch(data.action){ case "fullScreenIntent": case "contentTap": RNVoipCall.endAllCalls(); navigate("Modal", {screen: "IncomingCallScreen", params: data}) break; case "callAnswer": DeviceEventEmitter.emit("lds.accept_call", data); navigate('Modal', { screen: 'VideoCall', params: {headLess: false, isVideo: false, remote_user_uid: data.callerId}, }); break; case "missedCallTape": break; } }).catch(e=>console.log(e)); break;}
}; `
— Reply to this email directly, view it on GitHub https://github.com/ajith-ab/react-native-voip-call/issues/23#issuecomment-1480581569, or unsubscribe https://github.com/notifications/unsubscribe-auth/A22AVDTPCI5RHQQRYZESSZTW5PFO7ANCNFSM4XNHW6EA . You are receiving this because you commented.Message ID: @.***>
Yes. Although I placed it in index.android.js because this code I use only for android.
You can export above module and then call this AppRegistry.registerHeadlessTask("lds_bg", () => lds_bg);
Thanks, I'll check it out.
On Thu, Mar 23, 2023 at 10:48 AM hoangtu92 @.***> wrote:
You can export above module and then call this AppRegistry.registerHeadlessTask("lds_bg", () => lds_bg);
— Reply to this email directly, view it on GitHub https://github.com/ajith-ab/react-native-voip-call/issues/23#issuecomment-1480616639, or unsubscribe https://github.com/notifications/unsubscribe-auth/A22AVDQL4BAJLGYRY2RRR23W5PMKZANCNFSM4XNHW6EA . You are receiving this because you commented.Message ID: @.***>
Hey ,
I need your help in this package like in android 12 when receiving a call it just rings only and doesn't show a notification banner with two buttons 'answer' and 'decline'. So can you please let me know what changes I need to make in this package.
Thanks
On Thu, Mar 23, 2023 at 12:57 PM Karan Singh @.***> wrote:
Thanks, I'll check it out.
On Thu, Mar 23, 2023 at 10:48 AM hoangtu92 @.***> wrote:
You can export above module and then call this AppRegistry.registerHeadlessTask("lds_bg", () => lds_bg);
— Reply to this email directly, view it on GitHub https://github.com/ajith-ab/react-native-voip-call/issues/23#issuecomment-1480616639, or unsubscribe https://github.com/notifications/unsubscribe-auth/A22AVDQL4BAJLGYRY2RRR23W5PMKZANCNFSM4XNHW6EA . You are receiving this because you commented.Message ID: @.***>
You can test it out with a simple code that show a simple notification first. Also It's worth to check whether the phone is in silent/power saving mode or not.
Hey , I need your help in this package like in android 12 when receiving a call it just rings only and doesn't show a notification banner with two buttons 'answer' and 'decline'. So can you please let me know what changes I need to make in this package. Thanks On Thu, Mar 23, 2023 at 12:57 PM Karan Singh @.> wrote: … Thanks, I'll check it out. On Thu, Mar 23, 2023 at 10:48 AM hoangtu92 @.> wrote: > You can export above module and then call this AppRegistry.registerHeadlessTask("lds_bg", > () => lds_bg); > > — > Reply to this email directly, view it on GitHub > <#23 (comment)>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/A22AVDQL4BAJLGYRY2RRR23W5PMKZANCNFSM4XNHW6EA > . > You are receiving this because you commented.Message ID: > @.***> >
Use react-native-voips-calls, which have android 12+ support