react-native-webrtc / react-native-callkeep

iOS CallKit framework and Android ConnectionService for React Native
ISC License
920 stars 444 forks source link

how to detect a call declined iOS #432

Open khanhduy62 opened 3 years ago

khanhduy62 commented 3 years ago

I'm just wondering how anyone handles pressing wake/sleep button in iOS to decline an incoming call

Romick2005 commented 3 years ago

Have you read this?

What do you mean by wake/sleep button? For me you just need to catch decline event (it can be decline button on UI, physical decline button, it could be even some macro on shake action or anything else that cause call decline). So you will have this event or you would like to have some different behaviour.

Romick2005 commented 3 years ago

I assume that you do not have any events when app is closed. So you need to check your if your native side works. You can start app in debug mode from xcode and check logs there also I would recommend you to use my fork as there you can see clear picture of event order.

khanhduy62 commented 3 years ago

@Romick2005 I'm using "react-native-callkeep" with version "^4.1.0" now To be honest, I do not receive any events if I press wake/sleep button Here is my code:

Screen Shot 2021-05-28 at 5 37 31 PM
khanhduy62 commented 3 years ago

@Romick2005 I mean I still receive other events such as answer or cancel. However, I cannot get event for pressing wake/sleep button in order to decline a call

namnm commented 3 years ago

@khanhduy62 If after you press the button, the call end, then you should receive the endCall event. If you press the button and the call does not end, then there's no event.

CallKeep only care about call events like answer/reject, other key press events are not in responsibility

krupalikevadiya commented 3 years ago

Yes @namnm i got endCall event when call reject from lock screen(https://prnt.sc/1rltmuy) but my api calling is not working in case of lock screen. Same code is worked in case of device unlocked, Can you please suggest me any way to resolve it?

namnm commented 3 years ago

@krupalikevadiya Are you relying on component life-cycle? Components are not rendered in this case so all life-cycle did mount, did update... are useless.

Romick2005 commented 3 years ago

Yes @namnm i got endCall event when call reject from lock screen(https://prnt.sc/1rltmuy) but my api calling is not working in case of lock screen. Same code is worked in case of device unlocked, Can you please suggest me any way to resolve it?

You can use my fork and send reject call from objective-c code or o your server.

krupalikevadiya commented 3 years ago

Yaa @Romick2005 but i need some other parameters to pass in api and which is at JS side so api call through obj-c not working for me.

Romick2005 commented 3 years ago

@krupalikevadiya you can always pass parameters between js and native side using react-native-default-preference package. So I think it is not a problem.

krupalikevadiya commented 3 years ago

So did you mean we have to store that data in default preference when call is coming and use that data at obj-C side for api Call

Romick2005 commented 3 years ago

You need to store data from JS part first (assume that is authentication token). Then on incoming call you can get call UUID from push token for Android or voip for iOS. Next step is to merge this data and use for sending decline https request to your server from native code.

krupalikevadiya commented 3 years ago

That means need to store incoming call data at both side Obj-c and Js side right? and based on uuid we get other data of incoming push which we need to send https for reject call.

nero2009 commented 2 years ago

this

@Romick2005 Do I need to use your fork to implement this functionality(rejecting the call from the IOS native )?

Romick2005 commented 2 years ago

Yes, you can use it.