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

iPhone/iPad does not receive incoming calls when the phone/pad is on 'sleep' or 'lock' mode #121

Closed
saradavid16 opened this Issue Oct 6, 2016 · 18 comments

Comments

Projects
None yet
9 participants
@saradavid16
Copy link

saradavid16 commented Oct 6, 2016

Hello Everyone,

I have registered SIP account with our own sip server in TCP mode. Whenever the iPhone/iPad went to Sleep/Lock mode does not receive incoming call. Could you please suggest how do I overcome this issue.

@01CGAT

This comment has been minimized.

Copy link

01CGAT commented Oct 6, 2016

With the latest iOS10 SDK (Xcode 8) you need to configure Apple Push Notification Services (server-side) for background VOIP modus in combination with PushKit (client-side), older legacy VOIP background (non-PushKit) methods are not supported anymore, and will not work with the iOS 10 SDK. Or you can try to compile with iOS 9.3 SDK (only available with Xcode 7, not 8, as it can only use iOS 10 SDK) to make use of the old legacy VOIP background modus, which is probably only available in an old linphone-iphone version, 3.13.9 for example. Newer linphone-iphone versions only might have the newer VOIP PushKit functionality and not the legacy VOIP background functionality. With the legacy VOIP background modus compiled with the iOS 9.3 SDK you can have a TCP VOIP background modus without the need to configure Apple Push Notifications server-side, UDP will not work either, that is only supported in even older iOS SDK's. And this legacy TCP VOIP background modus is only active as long as the app is available in the background. If you completely quit the app, this background modus is not available either as long as you don't configure the Apple Push Notifications server-side. FYI: Apps compiled with the iOS 9.3 SDK will run on iOS 10 phones too.

@JFSene

This comment has been minimized.

Copy link

JFSene commented Oct 14, 2016

Im having the same problem, whenever the App is in the BG i get this:

linphone(4469,0x116ea4000) malloc: *** error for object 0x61800020f450: Invalid pointer dequeued from free list
*** set a breakpoint in malloc_error_break to debug
(lldb)

So i set a breakpoint and this is what i got:

Oct 14 10:25:50  linphone[5052] <Notice>: bel/Background task belle-sip recv channel started. Unknown remaining time since application is not fully in background.
Oct 14 10:25:50  linphone[5052] <Warning>: bel/channel [0x7fd4110dc000]: recv background task has to be ended now, but work isn't finished.
Oct 14 10:25:50  linphone[5052] <Notice>: bel/channel [0x7fd4110dc000]: starting recv background task with id=[11].
Oct 14 10:25:50  linphone[5052] <Notice>: bel/channel [0x7fd4110dc000]: ending recv background task with id=[11].
Oct 14 10:25:50  linphone[5052] <Notice>: bel/channel [0x7fd4110dc000]: received [996] new bytes from [UDP://fone.isuper.com.br:5060]:
    INVITE sip:280@177.8.248.2:60229;transport=udp SIP/2.0
    Via: SIP/2.0/UDP 177.8.248.10:5060;branch=z9hG4bK61ccf6d3;rport
    Max-Forwards: 70
    From: "Suporte-Matheus (240)" <sip:4432328777@177.8.248.10>;tag=as7911bb8f
    To: <sip:280@177.8.248.2:60229;transport=udp>
    Contact: <sip:4432328777@177.8.248.10:5060>
    Call-ID: 6f4752b8647e456e4d56a8da38ed2dcc@177.8.248.10:5060
    CSeq: 102 INVITE
    User-Agent: PhoneBox PBX
    Date: Fri, 14 Oct 2016 13:25:52 GMT
    Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
    Supported: replaces, timer
    Content-Type: application/sdp
    Content-Length: 373

    v=0
    o=root 117817306 117817306 IN IP4 177.8.248.10
    s=Asterisk PBX 11.13.1
    c=IN IP4 177.8.248.10
    t=0 0
    m=audio 11240 RTP/AVP 8 0 3 97 18 101
    a=rtpmap:8 PCMA/8000
    a=rtpmap:0 PCMU/8000
    a=rtpmap:3 GSM/8000
    a=rtpmap:97 iLBC/8000
    a=fmtp:97 mode=30
    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
Oct 14 10:25:50  linphone[5052] <Notice>: bel/channel [0x7fd4110dc000] [623] bytes parsed
Oct 14 10:25:50  linphone[5052] <Notice>: bel/channel [0x7fd4110dc000] read [373] bytes of body from [fone.isuper.com.br:5060]
Oct 14 10:25:50  linphone[5052] <Notice>: bel/Changing [server] [INVITE] transaction [0x600000540f20], from state [INIT] to [PROCEEDING]
Oct 14 10:25:50  linphone[5052] <Notice>: bel/channel [0x7fd4110dc000]: message sent to [UDP://fone.isuper.com.br:5060], size: [289] bytes
    SIP/2.0 100 Trying
    Via: SIP/2.0/UDP 177.8.248.10:5060;branch=z9hG4bK61ccf6d3;rport
    From: "Suporte-Matheus (240)" <sip:4432328777@177.8.248.10>;tag=as7911bb8f
    To: <sip:280@177.8.248.2:60229;transport=udp>
    Call-ID: 6f4752b8647e456e4d56a8da38ed2dcc@177.8.248.10:5060
    CSeq: 102 INVITE
Oct 14 10:25:50  linphone[5052] <Notice>: bel/New server dialog [0x6100001dbd50] , local tag [kubYzUv], remote tag [as7911bb8f]
Oct 14 10:25:50  linphone[5052] <Notice>: lib/op [0x7fd410d3e420] : set_or_update_dialog() current=[0x0] new=[0x6100001dbd50]
Oct 14 10:25:50  linphone[5052] <Notice>: lib/new incoming call from ["Suporte-Matheus (240)" <sip:4432328777@177.8.248.10>] to [<sip:280@177.8.248.2:60229;transport=udp>]
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Found payload PCMA/8000 fmtp=
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Found payload PCMU/8000 fmtp=
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Found payload GSM/8000 fmtp=
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Found payload iLBC/8000 fmtp=mode=30
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Found payload G729/8000 fmtp=annexb=no
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Found payload telephone-event/8000 fmtp=0-16
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Searching for already_a_call_with_remote_address.
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Found media local-ip from signaling.
Oct 14 10:25:50  linphone[5052] <Notice>: lib/New LinphoneCall [0x7fd41106f000] initialized (LinphoneCore version: 3.10.2-293-g8958eaa)
Oct 14 10:25:50  linphone[5052] <Notice>: lib/audio stream index found: 0, updating main audio stream index
Oct 14 10:25:50  linphone[5052] <Notice>: lib/RtpSession bound to [0.0.0.0] ports [7232] [7233]
Oct 14 10:25:50  linphone[5052] <Notice>: lib/rtp_session_enable_network_simulation:DISABLING NETWORK SIMULATION
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Configured srtp crypto suite: AES_CM_128_HMAC_SHA1_80 
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Configured srtp crypto suite: AES_CM_128_HMAC_SHA1_32 
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Configured srtp crypto suite: AES_256_CM_HMAC_SHA1_80 
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Configured srtp crypto suite: AES_256_CM_HMAC_SHA1_32 
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Creating ZRTP engine on rtp session [0x7fd411926000] ssrc 0x7081c90e
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Setting DSCP to 46 for MSAudio stream.
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Equalizer location: mic
Oct 14 10:25:50  linphone[5052] <Notice>: lib/cannot set noise gate mode to [0] because no volume send
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Cannot determine multicast role for stream type [video] on call [0x7fd41106f000]
Oct 14 10:25:50  linphone[5052] <Notice>: lib/RtpSession bound to [0.0.0.0] ports [9244] [9245]
Oct 14 10:25:50  linphone[5052] <Notice>: lib/rtp_session_enable_network_simulation:DISABLING NETWORK SIMULATION
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Initializing multistream ZRTP context on rtp session [0x7fd412129c00] ssrc 0x253348e2
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Setting DSCP to 0 for MSVideo stream.
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Cannot determine multicast role for stream type [text] on call [0x7fd41106f000]
Oct 14 10:25:50  linphone[5052] <Notice>: lib/RtpSession bound to [0.0.0.0] ports [11078] [11079]
Oct 14 10:25:50  linphone[5052] <Notice>: lib/rtp_session_enable_network_simulation:DISABLING NETWORK SIMULATION
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Created new ICE check list for stream [0]
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Found media local-ip from signaling.
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Don't put video stream on local offer for call [0x7fd41106f000]
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Don't put text stream on local offer for call [0x7fd41106f000]
Oct 14 10:25:50  linphone[5052] <Notice>: lib/Doing SDP offer/answer process of type incoming
Oct 14 10:25:50  linphone[5052] <Notice>: lib/No match for GSM/8000/1
Oct 14 10:25:50  linphone[5052] <Notice>: lib/No match for iLBC/8000/1
Oct 14 10:25:50  linphone[5052] <Notice>: lib/No match for G729/8000/1
Oct 14 10:25:50  linphone[5052] <Notice>: bel/Background task liblinphone call notification started. Unknown remaining time since application is not fully in background.
linphone(5052,0x10d380000) malloc: *** error for object 0x618000019cc0: Invalid pointer dequeued from free list
*** set a breakpoint in malloc_error_break to debug
(lldb) 

Any ideas?

@01CGAT

This comment has been minimized.

Copy link

01CGAT commented Oct 14, 2016

I don't know why you get the error, but I do know UDP is not supported for a VoIP background modus in Apple devices and that's what I see you're using for transport. Maybe switching to TCP solves everything.

@JFSene

This comment has been minimized.

Copy link

JFSene commented Oct 14, 2016

Thankyou Juiced!! Oh BTW i translated the whole iOS project to Portugueses(Brazilian) if you want to add it to the project, feel free.

PS. Didnt know how to tell you that, so ill just post it here =)

@01CGAT

This comment has been minimized.

Copy link

01CGAT commented Oct 14, 2016

Oh, I'm not an "official" member of this repository and I'm not affiliated with Belledonne Communications, just here trying to help people with what I find out thus far while working on Linphone for a project.
But I know you can translate stuff for Linphone on: https://www.transifex.com/belledonne-communications/public/
I see Portuguese (Brazilian) has the status "ready", so maybe you're the one who already found out about this website. ;-)

@TheEngineerz

This comment has been minimized.

Copy link

TheEngineerz commented Oct 26, 2016

@juiced please correct me if I am wrong . . . ,so you mean for now we should compile our app for iOS 9.3 and implement push kit inside app and apple VoIP push service on server end. In this way our background calling will work on iOS 9 & 10 both. Right ?

Actually I want to ask what is the best way if we want our app to receive call in background for iOS 9 and 10 both.?

@01CGAT

This comment has been minimized.

Copy link

01CGAT commented Oct 26, 2016

I'm not a core linphone developer, but from what I know/my experience: The best way is to go with the latest linphone version (which has PushKit code) and to go with an Apple Push Notification supported SIP server. The Apple PushKit framework is available since iOS 8.0. You don't need to compile for iPhone iOS 9.3, you can compile for iOS 8+ if you want, because PushKit is available since iOS8+.

I was talking about the 9.3 version of the iOS SDK (available in Xcode 7 and not available anymore in Xcode 8) and the need for compiling linphone against it when you need to use the older legacy TCP VOIP background modus of linphone (the non-PushKit VOIP background modus). This older legacy TCP VOIP background modus is slower/less reliable/more battery draining than PushKit, and not supported/not available when linphone is compiled against the iOS 10 SDK, you will see error messages in your linphone debug log.

If your SIP server is Apple Push Notification ready, then the way to go is to just use the latest version of everything. Xcode 8, iOS 10 SDK, compile the latest version of linphone for iOS 8+.

If your SIP server is not Apple Push Notification ready, you will get network error connect messages when using the latest versions of everything (with PushKit support in the app) and when taking the app out of the background, even when you turn off push notifications for the user account in the linphone app.
This is only from my experience and then I'm probably just doing something wrong.
In this case you can try to use the old legacy TCP VOIP background modus, for which you need to use Xcode 7, with iOS SDK9.3 or older where the legacy VOIP background modus is still supported, and maybe an older linphone version because this legacy VOIP modus code might have been removed in the latest versions of linphone.

@afriedmanGlacier

This comment has been minimized.

Copy link

afriedmanGlacier commented Nov 16, 2016

@juiced do you have any idea if the "Push Notification" switch in settings is related to the "older legacy TCP VOIP background modus" or to the PushKit VOIP background modus? In other words, if I want to use PushKit notifications, should that switch be on or off? And are there other things in the client that need to be set?

@01CGAT

This comment has been minimized.

Copy link

01CGAT commented Nov 16, 2016

Hi @afriedmanGlacier , unfortunately I cannot answer that question, as I'm still dealing with the legacy VOIP background modus myself. But if we can assume anything, I would assume that the switch should be turned on for PushKit VOIP background modus.

@JFSene

This comment has been minimized.

Copy link

JFSene commented Nov 16, 2016

Hello @juiced @afriedmanGlacier My app crashes everytime that switch is on, and i /* */ the legacy VOIP code, so my guess is that its related to the legacy code.

@afriedmanGlacier

This comment has been minimized.

Copy link

afriedmanGlacier commented Nov 17, 2016

@JFSene or @saradavid16 were you able to get Apple Push notifications working and receive incoming calls over TCP? If so, I'm wondering what SIP server you are using and if you have any additional tips for getting it to work?

@JFSene

This comment has been minimized.

Copy link

JFSene commented Nov 18, 2016

@afriedmanGlacier Yes and No. I used this https://github.com/JFSene/houston to send Pushes, very easy to use and can be applied to the server side and No, our PBX runs on a UDP connection, very handy to get it to work with apple, but worth it.

@TheEngineerz

This comment has been minimized.

Copy link

TheEngineerz commented Mar 22, 2017

@JFSene I am using freePBX for server side and Unfortunately don't know much about how to write service to send push to my app(basically i am only ios developer 😭). Can you please just show me direction or help me how check if call is coming from android or iPhone. I am trying to use Houston to send push.

@babumoshai-ankush

This comment has been minimized.

Copy link

babumoshai-ankush commented Apr 20, 2017

In old SDK (mid 2015) when I set transport to TCP, call is coming in foreground & background mode from remote server. But somehow the video is not establishing for both scenario. But when I set transport to UDP, video call establishing perfectly when the app is in foreground mode but didn't get notification in background mode.
Can you help me please.
Thanks in advance!

Regards,
Ankush

@mefsantos

This comment has been minimized.

Copy link

mefsantos commented May 1, 2017

@TheEngineerz Have a look at flexisip (http://www.linphone.org/technical-corner/flexisip/overview) it already comes prepared for push notifications and firebase (android). you just need to add the certificates and set the path in the server configurations. To test the Push Notifications (and VOIP notifications) you can always use Easy APNs Provider from the Mac AppStore (https://itunes.apple.com/us/app/easy-apns-provider-push-notification-service-testing-tool/id989622350?mt=12). With this app you just need to import the certificates to the app, connect to the server, add the app token and fill the text fields to complete the notification as you want.

@TheEngineerz

This comment has been minimized.

Copy link

TheEngineerz commented Jun 27, 2017

@mefsantos my server developer have configured the certificates and have written the basic push service. now he doesn't know what exactly needs to send to activate the Call Kit, so the user can receive a call in the background. Please advice what i should tell him

@ReisBenjamin

This comment has been minimized.

Copy link
Contributor

ReisBenjamin commented Aug 10, 2017

See Callkit apple doc please

@S0U1SB4N3

This comment has been minimized.

Copy link

S0U1SB4N3 commented Aug 20, 2017

You will have to create a VoIP certificate from Apple developer account then send a push notification right before the server sends the call and it will wake up the phone before the call is attempted. You need the server to get the token and store it for each sip account that uses the soft phone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment