react-native-voip-call icon indicating copy to clipboard operation
react-native-voip-call copied to clipboard

Hot to handle Reject Event

Open mg4u opened this issue 4 years ago • 10 comments

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

mg4u avatar Feb 10 '21 16:02 mg4u

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...

hoangtu92 avatar Apr 29 '21 08:04 hoangtu92

Can you please show some code so that can get idea for implementing your solution. Thanks

karan-sps avatar Mar 22 '23 09:03 karan-sps

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;
}

};

`

hoangtu92 avatar Mar 23 '23 04:03 hoangtu92

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: @.***>

karan-sps avatar Mar 23 '23 05:03 karan-sps

Yes. Although I placed it in index.android.js because this code I use only for android.

hoangtu92 avatar Mar 23 '23 05:03 hoangtu92

You can export above module and then call this AppRegistry.registerHeadlessTask("lds_bg", () => lds_bg);

hoangtu92 avatar Mar 23 '23 05:03 hoangtu92

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: @.***>

karan-sps avatar Mar 23 '23 07:03 karan-sps

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: @.***>

karan-sps avatar May 11 '23 10:05 karan-sps

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.

hoangtu92 avatar May 29 '23 01:05 hoangtu92

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

DeepikaSharma5 avatar Jul 19 '23 06:07 DeepikaSharma5