react-native-webrtc / react-native-callkit

#deprecated iOS 10 new CallKit framework for React Native
ISC License
122 stars 67 forks source link

Callkit view doesn't close #3

Open siemya opened 7 years ago

siemya commented 7 years ago

@ianlin Hey,

When i call the RNCallKit.endCall(this.uuid) function callkit view does not close.

Thanks for the module btw! 👍

ianlin commented 7 years ago

Hey @siemya,

Are you testing on the incoming calls or outgoing calls? The system UI is appeared only for incoming calls while endCall() method is used for outgoing calls.

For incoming calls, when you press the hangup button from the system UI, there is an endCall event (different from endCall() method) sent to JS and the module will call [action fulfill] automatically. The system UI will be closed after this.

Can you provide more information about your scenario and some logs could be helpful.

siemya commented 7 years ago

Thanks for the fast response!

When the app is n foreground and i receive a call, i call the RNCallKit.displayIncomingCall function which opens the system UI.

And if i accept that call the system UI goes to background automatically, and i show my own callView.

When the user presses the endCall button or if i receive an endCall event from the other user, i close my own view and call the RNCallKit.endCall(this.uuid) function.

However the system UI keeps appearing on the background...

Thanks.

ianlin commented 7 years ago

I think it happens when the uuid for displayIncomingCall() and endCall() are different. Can you verify your uuid?

siemya commented 7 years ago

@ianlin when i receive a remote call i set a uuid and display the call, and when i receive a remote hangup, i call the endCall event with the same uuid, but the ui doesn't close.

remoteCall() {
  this.uuid = uuid.v4();
  console.log(this.uuid); //a61405bc-252a-4057-b79e-5e971cc82688
  RNCallKit.displayIncomingCall(this.uuid, name);
}

hangUp() {
  console.log(this.uuid); //a61405bc-252a-4057-b79e-5e971cc82688
  RNCallKit.endCall(this.uuid);
  this.uuid = null;
}
ianlin commented 7 years ago

That's odd, I've only run into this problem when the uuid is not the same. Can you please provide any log (JS and Native) to see what happened there?

siemya commented 7 years ago

Hey,

i guess i found the problem, but it still doesn't work sometimes.

On my constructor i add the endCall event listener, and i have two hangup functions (hangUp, remoteHangUp).

İ make a call when the app is on foreground, and end the call immediately. So i expect only the remoteHangUp function to get called. However after remoteHangUp also hangUp function gets called which i added to eventListener, which might mix things up.

//i expect to call hangUp only when user presses the decline button.
RNCallKit.addEventListener('endCall', this.hangUp);

remoteHangUp() {
  RNCallKit.endCall(this.uuid);
  //other actions
}

hangUp() {
  RNCallKit.endCall(this.uuid);
  //other actions
}
ianlin commented 7 years ago

Had some tests and yes the endCall event will be triggered after every endCall action. But still I can't reproduce the problem you have even if I call RNCallKit.endCall() twice.

Instead of calling RNCallKit.endCall() in both of your hangup function, I would suggest put it in the signal event. For my case since I'm using SIP for signalling, I call it when terminated or cancel events received.

ianlin commented 7 years ago

Hey @siemya have you sorted out this problem?

eugenehp commented 7 years ago

@ianlin looks like there was a wrong UUID pointer. Now it works for me 👍

joshuaalpuerto commented 7 years ago

does anyone fixed this issue? Im having trouble calling endCall method

here's the code :

const _uuid = uuid.v4()

RNCallKit.displayIncomingCall(_uuid, "Translator") // <--- 2d506a4a-8c50-40cc-894c-c359c210fd74

setTimeout(() => {
      if (!_answered) {
        console.tron.log('should end call / missed call')
        console.tron.log({
          uuid: this._uuid // <--- 2d506a4a-8c50-40cc-894c-c359c210fd74
        })
        RNCallKit.endCall(_uuid)
      }
}, 10000)

Here's my log:

2017-07-10 11:00:55.572985+0800 TranslatorApp[2806:1089269] [RNCallKit][endCall] uuidString = 2d506a4a-8c50-40cc-894c-c359c210fd74
2017-07-10 11:00:55.573421+0800 TranslatorApp[2806:1089269] [RNCallKit][requestTransaction] transaction = <CXTransaction 0x181bdd30 UUID=C6AD163D-E00B-46EC-9E2A-C54FACE4E97B isComplete=0 actions=(
    "<CXEndCallAction 0x16fd0040 UUID=893A8730-1118-48CC-A60A-6E56FF1FFD30 state=0 commitDate=(null) callUUID=2D506A4A-8C50-40CC-894C-C359C210FD74 dateEnded=(null)>"
)>
2017-07-10 11:00:55.580380+0800 TranslatorApp[2806:1089398] [RNCallKit][requestTransaction] Error requesting transaction ((
    "<CXEndCallAction 0x16fd0040 UUID=893A8730-1118-48CC-A60A-6E56FF1FFD30 state=0 commitDate=(null) callUUID=2D506A4A-8C50-40CC-894C-C359C210FD74 dateEnded=(null)>"
)): (Error Domain=com.apple.CallKit.error.requesttransaction Code=4 "(null)")
2017-07-10 11:01:26.675633+0800 TranslatorApp[2806:1085467] [RNCallKit][CXProviderDelegate][provider:performEndCallAction]

Cheers!

eugenehp commented 7 years ago

Are you sending correct UUID here?

I feel like it would be great to store those uuids on level of this library, so if endCall is missing uuid, it could grab one from the cache.

On Sun, Jul 9, 2017 at 8:12 PM Joshua Alpuerto notifications@github.com wrote:

does anyone fixed this issue? Im having trouble calling endCall method

here's the code :

const _uuid = uuid.v4()

RNCallKit.displayIncomingCall(_uuid, "Translator") // <--- 2d506a4a-8c50-40cc-894c-c359c210fd74 setTimeout(() => { if (!_answered) { console.tron.log('should end call / missed call') console.tron.log({ uuid: this._uuid // <--- 2d506a4a-8c50-40cc-894c-c359c210fd74 }) RNCallKit.endCall(_uuid) } }, 10000)

Here's my log:

2017-07-10 11:00:55.572985+0800 TranslatorApp[2806:1089269] [RNCallKit][endCall] uuidString = 2d506a4a-8c50-40cc-894c-c359c210fd74 2017-07-10 11:00:55.573421+0800 TranslatorApp[2806:1089269] [RNCallKit][requestTransaction] transaction = <CXTransaction 0x181bdd30 UUID=C6AD163D-E00B-46EC-9E2A-C54FACE4E97B isComplete=0 actions=( "<CXEndCallAction 0x16fd0040 UUID=893A8730-1118-48CC-A60A-6E56FF1FFD30 state=0 commitDate=(null) callUUID=2D506A4A-8C50-40CC-894C-C359C210FD74 dateEnded=(null)>" )> 2017-07-10 11:00:55.580380+0800 TranslatorApp[2806:1089398] [RNCallKit][requestTransaction] Error requesting transaction (( "<CXEndCallAction 0x16fd0040 UUID=893A8730-1118-48CC-A60A-6E56FF1FFD30 state=0 commitDate=(null) callUUID=2D506A4A-8C50-40CC-894C-C359C210FD74 dateEnded=(null)>" )): (Error Domain=com.apple.CallKit.error.requesttransaction Code=4 "(null)") 2017-07-10 11:01:26.675633+0800 TranslatorApp[2806:1085467] [RNCallKit][CXProviderDelegate][provider:performEndCallAction]

Cheers!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ianlin/react-native-callkit/issues/3#issuecomment-313991531, or mute the thread https://github.com/notifications/unsubscribe-auth/ABxW71MyJVfS9NLdV7hQJ1RR-_UdzikHks5sMZaKgaJpZM4MW1EK .

joshuaalpuerto commented 7 years ago

HI @eugenehp

Yes I am. I actually thought I edited my post but your PR, solves my issue.

eugenehp commented 7 years ago

@joshuaalpuerto glad it helped you.

I'm still curious to hear what @ianlin thinks about improving architecture of the wrapper.

joshuaalpuerto commented 7 years ago

@eugenehp Sorry Im still new with mobile development, Im no expert of swift nor objective-c so I can't really comment on that. Anyway I experience a weird issue last night, Im trying to call endCall method and it is not triggering. I think it has something to do if the call goes wrong or something.

I have to put back this part on ios/RNCallKit/RNCallKit.m

+reportCallWithUUID:startCallAction.callUUID updated:callUpdate];
-reportCallWithUUID:startCallAction.UUID updated:callUpdate];

And It works again.

joshuaalpuerto commented 7 years ago

Hi @eugenehp ,

Im still encountering issue triggering endCall method.

Here is my Xcode's log:

RNCallKit][requestTransaction] Error requesting transaction ((
    "<CXEndCallAction 0x19f69cc0 UUID=FC02B203-768E-4179-8415-6021F7990C5C state=0 commitDate=(null) callUUID=612A5D2B-A337-41D4-9CA6-5EF0B656391D dateEnded=(null)>"
)): (Error Domain=com.apple.CallKit.error.requesttransaction Code=4 "(null)")

Im sure that this is what i registered with my displayIncomingCall: 612A5D2B-A337-41D4-9CA6-5EF0B656391D

Cheers!

talibasya commented 6 years ago

@joshuaalpuerto I noticed different behaviour on production and development version. In some cases endCall doesn't work properly on development deployment, but with production I don't have problems. Did you run app on prod version?

joshuaalpuerto commented 6 years ago

@talibasya Yes I run it with production build but still has issues. I think the problem is if the call was not established correctly.

vyshkant commented 6 years ago

@joshuaalpuerto have you finally solved the problem?

vyshkant commented 6 years ago

The system UI is appeared only for incoming calls while endCall() method is used for outgoing calls.

@ianlin And what is the proper way to hide the incoming call screen when the call is terminated "from the other side" (i.e. the red button wasn't pressed by the user).

2018-07-30 19:57:31.461329+0300 MyProject[875:3717380] [RNCallKit][displayIncomingCall] uuidString = fcf1ad00-e4ae-48ef-a6be-0ced08209373

2018-07-30 19:57:38.971502+0300 MyProject[875:3722596] [RNCallKit][endCall] uuidString = fcf1ad00-e4ae-48ef-a6be-0ced08209373
2018-07-30 19:57:38.972359+0300 MyProject[875:3722596] [RNCallKit][requestTransaction] transaction = <CXTransaction 0x125e352c0 UUID=D0CA94B2-5888-4029-8BE7-11B3A02BB2A1 isComplete=0 actions=(
    "<CXEndCallAction 0x125e0aa60 UUID=37C172A4-5FC3-4775-A0D1-EA7BE33F3957 state=0 commitDate=(null) callUUID=FCF1AD00-E4AE-48EF-A6BE-0CED08209373 dateEnded=(null)>"
)>

2018-07-30 19:57:38.996998+0300 MyProject[875:3722596] [RNCallKit][requestTransaction] Error requesting transaction ((
    "<CXEndCallAction 0x125e0aa60 UUID=37C172A4-5FC3-4775-A0D1-EA7BE33F3957 state=0 commitDate=(null) callUUID=FCF1AD00-E4AE-48EF-A6BE-0CED08209373 dateEnded=(null)>"
)): (Error Domain=com.apple.CallKit.error.requesttransaction Code=4 "(null)")

So I have the same problem: the incoming call screen is not closed when I invoke RNCallKit.endCall. The only difference between these uuids is the case (I generate lowercased uuid).

bmp123 commented 5 years ago

I have same issue. app received call then open displayIncomingCall . if app go to background and app receive event end call from server - displayIcomingCall UI works, but app invoke endCall function