Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot to handle Reject Event #23

Open
mg4u opened this issue Feb 10, 2021 · 10 comments
Open

Hot to handle Reject Event #23

mg4u opened this issue Feb 10, 2021 · 10 comments

Comments

@mg4u
Copy link

mg4u commented Feb 10, 2021

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

@hoangtu92
Copy link

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

@karan-sps
Copy link

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

@hoangtu92
Copy link

hoangtu92 commented Mar 23, 2023

You can check my fork: 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;
}

};

`

@karan-sps
Copy link

karan-sps commented Mar 23, 2023 via email

@hoangtu92
Copy link

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

@hoangtu92
Copy link

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

@karan-sps
Copy link

karan-sps commented Mar 23, 2023 via email

@karan-sps
Copy link

karan-sps commented May 11, 2023 via email

@hoangtu92
Copy link

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.

@DeepikaSharma5
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants