VoIPGRID / VialerSIPLib

An Objective-c wrapper for PJSIP
GNU General Public License v3.0
133 stars 69 forks source link

Nothing happens when there is Incoming Call #207

Open mrfarukturgut opened 4 years ago

mrfarukturgut commented 4 years ago

File / Feature

Example Project

Expected behavior

The app should show incoming call page and ringtone should play.

Actual behavior

Nothing happens at UI. However it logs about an incoming call.

Stacktrace / Error message


πŸ’š DEBUG   16:56:51.585 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  .RX 1261 bytes Request msg INVITE/cseq=102 (rdata0x7f8fe3096228) from UDP 255.255.255.255:5060:
INVITE sip:elk-269-ext@78.160.214.49:61203;ob SIP/2.0
Via: SIP/2.0/UDP 255.255.255.255:5060;branch=z9hG4bK361f02f1;rport
Max-Forwards: 70
From: "Dahili Abone 287" <sip:287@255.255.255.255>;tag=as35f867f8
To: <sip:elk-269-ext@78.160.214.49:61203;ob>
Contact: <sip:287@255.255.255.255:5060>
Call-ID: 3e5eb30170c301be6070fe315813fb5f@255.255.255.255:5060
CSeq: 102 INVITE
User-Agent: voipServer V4
Date: Thu, 27 Feb 2020 13:56:50 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
P-Asserted-Identity: "Dahili Abone 287" <sip:287@255.255.255.255>
Content-Type: application/sdp
Content-Length: 595

v=0
o=root 392798714 392798714 IN IP4 255.255.255.255
s=Asterisk PBX certified/11.6-cert14
c=IN IP4 255.255.255.255
b=CT:384
t=0 0
m=audio 14644 RTP/AVP 0 8 18 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
m=video 12440 RTP/AVP 98 31 99
a=rtpmap:98 h263-1998/90000
a=fmtp:98 F=0;I=0;J=0;T=0;K=0;N=0;BPP=0;HRD=0
a=rtpmap:31 H261/90000
a=rtpmap:99 H264/90000
a=fmtp:99 redundant-pic-cap=0;parameter-add=0;packetization-mode=0;level-asymmetry-allowed=0
a=sendrecv

--end msg--
πŸ’š DEBUG   16:56:51.613 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_call.c  .Incoming Request msg INVITE/cseq=102 (rdata0x7f8fe3096228)
πŸ’š DEBUG   16:56:51.613 [VSLEndpoint void logCallBack(int, const char *, int):539]          pjsua_media.c  ..Call 0: initializing media..
πŸ’š DEBUG   16:56:51.614 [VSLEndpoint void logCallBack(int, const char *, int):539]          pjsua_media.c  ...RTP socket reachable at 192.168.1.50:4004
πŸ’š DEBUG   16:56:51.614 [VSLEndpoint void logCallBack(int, const char *, int):539]          pjsua_media.c  ...RTCP socket reachable at 192.168.1.50:4005
πŸ’š DEBUG   16:56:51.615 [VSLEndpoint void logCallBack(int, const char *, int):539]          pjsua_media.c  ...RTP socket reachable at 192.168.1.50:4006
πŸ’š DEBUG   16:56:51.615 [VSLEndpoint void logCallBack(int, const char *, int):539]          pjsua_media.c  ...RTCP socket reachable at 192.168.1.50:4007
πŸ’š DEBUG   16:56:51.615 [VSLEndpoint void logCallBack(int, const char *, int):539]          pjsua_media.c  ...Media index 0 selected for audio call 0
πŸ’š DEBUG   16:56:51.616 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  .....TX 325 bytes Response msg 100/INVITE/cseq=102 (tdta0x7f8fe3899ea8) to UDP 255.255.255.255:5060:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 255.255.255.255:5060;rport=5060;received=255.255.255.255;branch=z9hG4bK361f02f1
Call-ID: 3e5eb30170c301be6070fe315813fb5f@255.255.255.255:5060
From: "Dahili Abone 287" <sip:287@255.255.255.255>;tag=as35f867f8
To: <sip:elk-269-ext@78.160.214.49;ob>
CSeq: 102 INVITE
Content-Length:  0

--end msg--
πŸ’œ VERBOSE 16:56:51.619 [VSLEndpoint void onIncomingCall(pjsua_acc_id, pjsua_call_id, pjsip_rx_data *):703] PJSUA callback: incoming call.
πŸ’™ INFO    16:56:51.619 [VSLEndpoint void onIncomingCall(pjsua_acc_id, pjsua_call_id, pjsip_rx_data *):707] Detected inbound call(0) for account:0
πŸ’› WARNING 16:56:51.619 [VSLEndpoint void onIncomingCall(pjsua_acc_id, pjsua_call_id, pjsip_rx_data *):723] Could not find a call with if 0.
πŸ’š DEBUG   16:56:51.619 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  .RX 1261 bytes Request msg INVITE/cseq=102 (rdata0x7f8fe3096228) from UDP 255.255.255.255:5060:
INVITE sip:elk-269-ext@78.160.214.49:61203;ob SIP/2.0
Via: SIP/2.0/UDP 255.255.255.255:5060;branch=z9hG4bK361f02f1;rport
Max-Forwards: 70
From: "Dahili Abone 287" <sip:287@255.255.255.255>;tag=as35f867f8
To: <sip:elk-269-ext@78.160.214.49:61203;ob>
Contact: <sip:287@255.255.255.255:5060>
Call-ID: 3e5eb30170c301be6070fe315813fb5f@255.255.255.255:5060
CSeq: 102 INVITE
User-Agent: voipServer V4
Date: Thu, 27 Feb 2020 13:56:50 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
P-Asserted-Identity: "Dahili Abone 287" <sip:287@255.255.255.255>
Content-Type: application/sdp
Content-Length: 595

v=0
o=root 392798714 392798714 IN IP4 255.255.255.255
s=Asterisk PBX certified/11.6-cert14
c=IN IP4 255.255.255.255
b=CT:384
t=0 0
m=audio 14644 RTP/AVP 0 8 18 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
m=video 12440 RTP/AVP 98 31 99
a=rtpmap:98 h263-1998/90000
a=fmtp:98 F=0;I=0;J=0;T=0;K=0;N=0;BPP=0;HRD=0
a=rtpmap:31 H261/90000
a=rtpmap:99 H264/90000
a=fmtp:99 redundant-pic-cap=0;parameter-add=0;packetization-mode=0;level-asymmetry-allowed=0
a=sendrecv

--end msg--
πŸ’š DEBUG   16:56:51.643 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  ..TX 325 bytes Response msg 100/INVITE/cseq=102 (tdta0x7f8fe3899ea8) to UDP 255.255.255.255:5060:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 255.255.255.255:5060;rport=5060;received=255.255.255.255;branch=z9hG4bK361f02f1
Call-ID: 3e5eb30170c301be6070fe315813fb5f@255.255.255.255:5060
From: "Dahili Abone 287" <sip:287@255.255.255.255>;tag=as35f867f8
To: <sip:elk-269-ext@78.160.214.49;ob>
CSeq: 102 INVITE
Content-Length:  0

--end msg--
πŸ’š DEBUG   16:56:51.647 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  .RX 1261 bytes Request msg INVITE/cseq=102 (rdata0x7f8fe404e028) from UDP 255.255.255.255:5060:
INVITE sip:elk-269-ext@78.160.214.49:61203;ob SIP/2.0
Via: SIP/2.0/UDP 255.255.255.255:5060;branch=z9hG4bK361f02f1;rport
Max-Forwards: 70
From: "Dahili Abone 287" <sip:287@255.255.255.255>;tag=as35f867f8
To: <sip:elk-269-ext@78.160.214.49:61203;ob>
Contact: <sip:287@255.255.255.255:5060>
Call-ID: 3e5eb30170c301be6070fe315813fb5f@255.255.255.255:5060
CSeq: 102 INVITE
User-Agent: voipServer V4
Date: Thu, 27 Feb 2020 13:56:50 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
P-Asserted-Identity: "Dahili Abone 287" <sip:287@255.255.255.255>
Content-Type: application/sdp
Content-Length: 595

v=0
o=root 392798714 392798714 IN IP4 255.255.255.255
s=Asterisk PBX certified/11.6-cert14
c=IN IP4 255.255.255.255
b=CT:384
t=0 0
m=audio 14644 RTP/AVP 0 8 18 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
m=video 12440 RTP/AVP 98 31 99
a=rtpmap:98 h263-1998/90000
a=fmtp:98 F=0;I=0;J=0;T=0;K=0;N=0;BPP=0;HRD=0
a=rtpmap:31 H261/90000
a=rtpmap:99 H264/90000
a=fmtp:99 redundant-pic-cap=0;parameter-add=0;packetization-mode=0;level-asymmetry-allowed=0
a=sendrecv

--end msg--
πŸ’š DEBUG   16:56:51.669 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  ..TX 325 bytes Response msg 100/INVITE/cseq=102 (tdta0x7f8fe3899ea8) to UDP 255.255.255.255:5060:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 255.255.255.255:5060;rport=5060;received=255.255.255.255;branch=z9hG4bK361f02f1
Call-ID: 3e5eb30170c301be6070fe315813fb5f@255.255.255.255:5060
From: "Dahili Abone 287" <sip:287@255.255.255.255>;tag=as35f867f8
To: <sip:elk-269-ext@78.160.214.49;ob>
CSeq: 102 INVITE
Content-Length:  0

--end msg--
πŸ’š DEBUG   16:57:20.869 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  .RX 379 bytes Request msg CANCEL/cseq=102 (rdata0x7f8fe204d428) from UDP 255.255.255.255:5060:
CANCEL sip:elk-269-ext@78.160.214.49:61203;ob SIP/2.0
Via: SIP/2.0/UDP 255.255.255.255:5060;branch=z9hG4bK361f02f1;rport
Max-Forwards: 70
From: "Dahili Abone 287" <sip:287@255.255.255.255>;tag=as35f867f8
To: <sip:elk-269-ext@78.160.214.49:61203;ob>
Call-ID: 3e5eb30170c301be6070fe315813fb5f@255.255.255.255:5060
CSeq: 102 CANCEL
User-Agent: voipServer V4
Content-Length: 0

--end msg--
πŸ’œ VERBOSE 16:57:20.874 [VSLEndpoint void onTxStateChange(pjsua_call_id, pjsip_transaction *, pjsip_event *):687] PJSUA callback: transaction within the call has changed state.
πŸ’š DEBUG   16:57:20.874 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  .......TX 358 bytes Response msg 200/CANCEL/cseq=102 (tdta0x7f8fe3859ca8) to UDP 255.255.255.255:5060:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 255.255.255.255:5060;rport=5060;received=255.255.255.255;branch=z9hG4bK361f02f1
Call-ID: 3e5eb30170c301be6070fe315813fb5f@255.255.255.255:5060
From: "Dahili Abone 287" <sip:287@255.255.255.255>;tag=as35f867f8
To: <sip:elk-269-ext@78.160.214.49;ob>;tag=P.Tpj47qO-BW2SFqhljCpCpC0Z8ZMAtj
CSeq: 102 CANCEL
Content-Length:  0

--end msg--
πŸ’œ VERBOSE 16:57:20.879 [VSLEndpoint void onTxStateChange(pjsua_call_id, pjsip_transaction *, pjsip_event *):687] PJSUA callback: transaction within the call has changed state.
πŸ’š DEBUG   16:57:20.879 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  .......TX 374 bytes Response msg 487/INVITE/cseq=102 (tdta0x7f8fe3899ea8) to UDP 255.255.255.255:5060:
SIP/2.0 487 Request Terminated
Via: SIP/2.0/UDP 255.255.255.255:5060;rport=5060;received=255.255.255.255;branch=z9hG4bK361f02f1
Call-ID: 3e5eb30170c301be6070fe315813fb5f@255.255.255.255:5060
From: "Dahili Abone 287" <sip:287@255.255.255.255>;tag=as35f867f8
To: <sip:elk-269-ext@78.160.214.49;ob>;tag=P.Tpj47qO-BW2SFqhljCpCpC0Z8ZMAtj
CSeq: 102 INVITE
Content-Length:  0

--end msg--
πŸ’œ VERBOSE 16:57:20.884 [VSLEndpoint void onTxStateChange(pjsua_call_id, pjsip_transaction *, pjsip_event *):687] PJSUA callback: transaction within the call has changed state.
πŸ’œ VERBOSE 16:57:20.884 [VSLEndpoint void onCallState(pjsua_call_id, pjsip_event *):577] PJSUA callback: call state changed.
πŸ’› WARNING 16:57:20.884 [VSLEndpoint void onCallState(pjsua_call_id, pjsip_event *):587] Received updated CallState(VSLCallStateDisconnected) for UNKNOWN call(id: 0)
πŸ’š DEBUG   16:57:20.884 [VSLEndpoint void logCallBack(int, const char *, int):539]          pjsua_media.c  ..........Call 0: deinitializing media..
πŸ’š DEBUG   16:57:20.884 [VSLEndpoint void logCallBack(int, const char *, int):539]          pjsua_media.c  ...........Call 0: cleaning up provisional media, prov_med_cnt=2, med_cnt=0
πŸ’š DEBUG   16:57:20.937 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  .RX 450 bytes Request msg ACK/cseq=102 (rdata0x7f8fe204d428) from UDP 255.255.255.255:5060:
ACK sip:elk-269-ext@78.160.214.49:61203;ob SIP/2.0
Via: SIP/2.0/UDP 255.255.255.255:5060;branch=z9hG4bK361f02f1;rport
Max-Forwards: 70
From: "Dahili Abone 287" <sip:287@255.255.255.255>;tag=as35f867f8
To: <sip:elk-269-ext@78.160.214.49:61203;ob>;tag=P.Tpj47qO-BW2SFqhljCpCpC0Z8ZMAtj
Contact: <sip:287@255.255.255.255:5060>
Call-ID: 3e5eb30170c301be6070fe315813fb5f@255.255.255.255:5060
CSeq: 102 ACK
User-Agent: voipServer V4
Content-Length: 0

--end msg--
πŸ’š DEBUG   16:57:29.867 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  .RX 571 bytes Request msg OPTIONS/cseq=102 (rdata0x7f8fe204d428) from UDP 255.255.255.255:5060:
OPTIONS sip:elk-269-ext@78.160.214.49:61203;ob SIP/2.0
Via: SIP/2.0/UDP 255.255.255.255:5060;branch=z9hG4bK7a88a9f9;rport
Max-Forwards: 70
From: "voipServer" <sip:voipServer@255.255.255.255>;tag=as64e87ae3
To: <sip:elk-269-ext@78.160.214.49:61203;ob>
Contact: <sip:voipServer@255.255.255.255:5060>
Call-ID: 472cf45d76f6466332e58d752ad5eda6@255.255.255.255:5060
CSeq: 102 OPTIONS
User-Agent: voipServer V4
Date: Thu, 27 Feb 2020 13:57:29 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0

--end msg--
πŸ’š DEBUG   16:57:29.876 [VSLEndpoint void logCallBack(int, const char *, int):539]           pjsua_core.c  .TX 750 bytes Response msg 200/OPTIONS/cseq=102 (tdta0x7f8fe30910a8) to UDP 255.255.255.255:5060:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 255.255.255.255:5060;rport=5060;received=255.255.255.255;branch=z9hG4bK7a88a9f9
Call-ID: 472cf45d76f6466332e58d752ad5eda6@255.255.255.255:5060
From: "voipServer" <sip:voipServer@255.255.255.255>;tag=as64e87ae3
To: <sip:elk-269-ext@78.160.214.49;ob>;tag=z9hG4bK7a88a9f9
CSeq: 102 OPTIONS
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Accept: application/sdp, application/pidf+xml, application/xpidf+xml, application/simple-message-summary, message/sipfrag;version=2.0, application/im-iscomposing+xml, text/plain
Supported: replaces, 100rel, timer, norefersub
Allow-Events: presence, message-summary, refer
User-Agent: VialerSIPLib Example App
Content-Length:  0

--end msg--

Other info

Calling from the example project to another softphone application works like a charm. I have encountered another error about pjsip and fixed it by giving "useVideo" parameter of the endpoint true like this;

endpointConfiguration.disableVideoSupport = prefs.bool(forKey: "useVideo")

The error was about validating the SDP as follows;

Assertion failed: ((status=pjmedia_sdp_validate(l_sdp))==PJ_SUCCESS), function pjsip_inv_verify_request3, file ../src/pjsip-ua/sip_inv.c, line 1183.

Solution is from; https://www.spinics.net/lists/pjsip/msg18883.html

Another thing is I am trying to call the app which is running on a simulator. And they have different IPs.

Finally I changed the server IP to 255.255.255.255

mrfarukturgut commented 4 years ago

When I added the following lines to the method onIncomingCall in VSLEndpoint.m, it is ringing on the caller side. However there is no ringing on your example project. Nothing happends. CallKitProviderDelegate does not response to anything.

        VSLCallManager *callManager = [VialerSIPLib sharedInstance].callManager;
        VSLLogInfo(@"call: ** %@", [callManager callsForAccount:account]);
        VSLCall *_call = [[VSLCall alloc] initInboundCallWithCallId:call_id account:account];
        [callManager addCall:_call];
        VSLCall *call = [callManager lastCallForAccount:account]; // TODO: safe to say that the last one is the right one?
mrfarukturgut commented 4 years ago

@arjenfvellinga @smolskyaleksey @jeremynorman89 @ChrisKontosEU any interest to help, please?

arjenfvellinga commented 4 years ago

About you addition of the 2 lines in the onIncomingCall method:

        VSLCall *_call = [[VSLCall alloc] initInboundCallWithCallId:call_id account:account];
        [callManager addCall:_call];

We init and add the call in the func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith method. See the changes Apple made regarding handling incoming push messages for incoming calls see https://forums.developer.apple.com/thread/117939

We are working on our own app to deal with these changes. There are changes to the library, but we didn't update the example app yet. So that could be the reason the incoming call is not working.

arjenfvellinga commented 4 years ago

The simulator can not get incoming push notifications (I think), so therefor incoming calls won't work

mrfarukturgut commented 4 years ago

I converted to 3.5.6 version and it works after some try. Can you please how do you get the call from didReceiveIncomingPushWith and after init it to the callManager. Can you give some code sample? Lastly, is it possible to implement my own CallKit delegation using the library?

arjenfvellinga commented 4 years ago

This is our code

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
    guard type == .voIP else { return }

    // Extract the call information from the push notification payload.
    if let phoneNumberString = payload.dictionaryPayload[PushedCall.MiddlewareAPNSPayloadKeyPhonenumber] as? String,
        let uuidString = payload.dictionaryPayload[PushedCall.MiddlewareAPNSPayloadKeyUniqueKey] as? String {
        // The uuid string in the payload is missing hyphens so fix that.
        let callUUID = NSUUID.uuidFixer(uuidString: uuidString)! as UUID

        // Configure the call information data structures.
        let callUpdate = CXCallUpdate()
        let phoneNumberHandle = CXHandle(type: .phoneNumber, value: phoneNumberString)
        callUpdate.remoteHandle = phoneNumberHandle
        callUpdate.localizedCallerName = phoneNumberString
        if let callerId = payload.dictionaryPayload[PushedCall.MiddlewareAPNSPayloadKeyCallerId] as? String {
            callUpdate.localizedCallerName = callerId
        }

        VialerLogDebug("Reporting a new call to CallKit provider with UUID: \(String(describing: callUUID.uuidString))")
        appDelegate.callKitProviderDelegate.provider.reportNewIncomingCall(with: callUUID, update: callUpdate, completion: { (error) in
            if error == nil {  // The call is not blocked by DnD or blacklisted by the iPhone, so continue processing the call. At this stage account is not available - sip invite has not arrived yet.

                if let newCall = VSLCall(inboundCallWith: callUUID, number: phoneNumberString, name:callUpdate.localizedCallerName ?? "") {
                    let callManager =  VialerSIPLib.sharedInstance().callManager
                    callManager.add(newCall)

                    DispatchQueue.main.async {
                        self.middleware.handleReceivedAPSNPayload(payload.dictionaryPayload)
                    }
                }
            }
            // Tell PushKit that the notification is handled.
            completion()
        })
    }
}

So after this and some time the sip invite arrives in the onIncomingCall method, and the call could be retrieved from the call manager (without your 2 added lines) .

Not sure what you mean with "is it possible to implement my own CallKit delegation using the library?"

mrfarukturgut commented 4 years ago

Thanks for your answer. I will use it if I update the library to the current version. I made it work for version 3.5.6 with helps from @mudassirzulfiqar. So now, I can get calls and make outgoing calls.

But there is problem with the implemation of the CallKit in the example project. It was working showing the native UI when there is a incoming call however when I answer it, it is switching to the UI which you have designed. I want to convert it to the native UI as well, for both incoming and outgoing calls. So I disabled the CallKitProviderDelegate.m references in the example project and implemented them on my own from your obj-c to swift in the AppDelegate. However right now when there is an incoming call, it shows the native UI but when I answer it -even though audio session is working- it just flashes the native UI that has mute, audio output, audio session lenght, caller number etc and then goes back to the lastest page of the app. But sound is working.

I asked it because of this situtation.

arjenfvellinga commented 4 years ago

I understand what you'te trying to achieve. sadly I can't help with that. We are aware that the example app is not up-to-date anymore, but unfortunately we currently have no time to spend time on it.

Good you have incoming calls working. Does that complies with the changes introduced with iOS 13 / Apple I linked earlier?

mrfarukturgut commented 4 years ago

If you are saying whether I implemented the PKPushRegistry or not, no I did not. Thanks for your help.

ChrisKontosEU commented 4 years ago

The simulator cannot get push notifications so do not expect incoming calls there. The example project as Arjen mentioned is currently outdated. Would be great if someone could pick it up and repair it with a pull request. After all this is an opensource project.

mrfarukturgut commented 4 years ago

Yeah I did not know that the Simulator was not be able to get notifications and now learned the hard way :) After I finish the this project, if I have some free time I would help you to not just update the example project but also converting the lib to the swift.

mrfarukturgut commented 4 years ago

@arjenfvellinga Hey, due to your answer regards to PushKit; how are you managing to get info about the call itself and report it to the CallKit. You have something called PushedCall in your code and it is not included in the library. I am not able to examine the payloadDictionary as it turned out that method is not working when CallKit is not notified. As I can not notify the CallKit this method not working and I can not learn what is what

arjenfvellinga commented 4 years ago

@mrfarukturgut A colleague of mine will get back to you with an answer.

jeremynorman89 commented 4 years ago

@arjenfvellinga Hey, due to your answer regards to PushKit; how are you managing to get info about the call itself and report it to the CallKit. You have something called PushedCall in your code and it is not included in the library. I am not able to examine the payloadDictionary as it turned out that method is not working when CallKit is not notified. As I can not notify the CallKit this method not working and I can not learn what is what

The payload contains information sent by your push server, in our case we are sending a call id and the name/number of the caller. This is the information that can be used to immediately launch the call kit, and then the actual sip call is tied based on the call id when it has been created.

With iOS 13 the main thing to be aware of is you must only send one push message per call. At least in our previous implementations we would send multiple push messages to make sure the phone got them, this will result in crashes in iOS 13.

krishnastvSMSC commented 4 years ago

hello arjenfvellinga, I tried the same thing for VOIP notification callback but I got error as PJSIP_ESESSIONTERMINATED as invited is terminated. please help up me to resolve this issue. Thank you

jeremynorman89 commented 4 years ago

hello arjenfvellinga, I tried the same thing for VOIP notification callback but I got error as PJSIP_ESESSIONTERMINATED as invited is terminated. please help up me to resolve this issue. Thank you

We re-wrote our APNS handling code, you can see it here: https://github.com/VoIPGRID/vialer-ios/tree/master/Vialer/Push with PushKitManager being the entry point that is called by APNS when a notification is received.

krishnastvSMSC commented 4 years ago

hello arjenfvellinga, I tried the same thing for VOIP notification callback but I got error as PJSIP_ESESSIONTERMINATED as invited is terminated. please help up me to resolve this issue. Thank you

We re-wrote our APNS handling code, you can see it here: https://github.com/VoIPGRID/vialer-ios/tree/master/Vialer/Push with PushKitManager being the entry point that is called by APNS when a notification is received.

Hello jeremynorman89, Thank you for your reply. I stuck at one thing unique_key from VOIP push notification, what this key refer and how it will link to the opposite person initiated call.

For the reference will let you know clearly,

I want to initiate a call from A to B :

Case 1: Both Online when ever I open the apps, register or SIP clients to our server. And initiating a call using startCallToNumber method, at B side automatically incomingCall block is executing the request with callId and sipInvite.

Case 2: B is Offline From A side,I register my A client to backend server with SIP profile. When ever I initiate a call from A to B, sending A side VSLCall call UUID to server. And server will look after of B status , if B is offline will send one VOIP push notification to B. At the B side when ever I got VOIP notification register the SIP client to server once registration is done, creating a VSLCall object using client A created VSLCall UUID. When ever I answer the call getting error at _pjsua_call_answer2 method as (char [80]) statusmsg = "INVITE session already terminated (PJSIP_ESESSIONTERMINATED)"._

So, I got stuck what is the id we need to pass to link the call from A to B.As I observer new VoIPPushHandler its taking unique_key of VOIP payload to create call object.what is this value for unique_key?

Can you please help me to resolve this issue.

Thank you.

jeremynorman89 commented 4 years ago

So, I got stuck what is the id we need to pass to link the call from A to B.As I observer new VoIPPushHandler its taking unique_key of VOIP payload to create call object.what is this value for unique_key?

Can you please help me to resolve this issue.

Thank you.

It's the Call-ID that we add hyphens to so it conforms to a UUID. However, I don't think it matters, any UUID should do. But you do need to make sure that the call is created when your push notification arrives, before you begin registering with SIP. As you can see onIncomingCall expects the call object to already be created:

https://github.com/VoIPGRID/VialerSIPLib/blob/0e2af1b813ab4e9cad48f525307fd901e659bcb8/Pod/Classes/VSLEndpoint.m#L742

krishnastvSMSC commented 4 years ago

Hello

So, I got stuck what is the id we need to pass to link the call from A to B.As I observer new VoIPPushHandler its taking unique_key of VOIP payload to create call object.what is this value for unique_key? Can you please help me to resolve this issue. Thank you.

It's the Call-ID that we add hyphens to so it conforms to a UUID. However, I don't think it matters, any UUID should do. But you do need to make sure that the call is created when your push notification arrives, before you begin registering with SIP. As you can see onIncomingCall expects the call object to already be created:

https://github.com/VoIPGRID/VialerSIPLib/blob/0e2af1b813ab4e9cad48f525307fd901e659bcb8/Pod/Classes/VSLEndpoint.m#L742

Thanks for the response,as I tried VSLCall *call = [callManager lastCallForAccount:account]; also got same error because CallKit is initiating the call, in the meanwhile I am registered the SIP account for getting invite its taking time. I tried reinviteActiveCallsForAccount also to get existing invites to process it won't help.

krishnastvSMSC commented 4 years ago

Hi Team, Finally I did it, with dummy callUUID, and answer the call when user answered. But for milliseconds till the SIP Invite came, its blank call and updating the existing call with new VCLCall object.

Thank you

shaydvir commented 3 years ago

@jeremynorman89 @krishnastvSMSC

Hi guys, The only thing that I'm missing, is what happen if the user answer the call before this sip is registered? When it happens, I get the following error: Could not answer call PJSIP returned status: INVITE session already terminated (PJSIP_ESESSIONTERMINATED) Error answering call() error:Error Domain=VialerSIPLib.VSLCall Code=2 "Could not answer call" UserInfo={NSLocalizedDescription=Could not answer call, NSLocalizedFailureReason=PJSIP status code: 171140}

in such case, the call is not established, and the receiver see the call screen with "cancel/dial back" and the caller still hearing the ringing tone.

any ideas how to overcome this?

Best regards!

fukemy commented 3 years ago

@shaydvir i got same problem : "INVITE session already terminated", did u solved this?

shaydvir commented 3 years ago

Hi @fukemy ,

I don't exactly remember how we nailed it, I think it was using asyncAfter() in order to register the call after the SIP is registered.

fukemy commented 3 years ago

tks, let me try