flutter-webrtc / callkeep

iOS CallKit and Android ConnectionService for Flutter
MIT License
138 stars 150 forks source link

[question] why stop the process to show incoming call in case `aps != nil`? #129

Open oisikurumeronpan opened 3 years ago

oisikurumeronpan commented 3 years ago

Hi. I would like to use this library to display the CallKit UI of iOS. However, the current implementation does not match the iOS notification payload specification in some places, so I would like to know why it is implemented the way it is.

The relevant code is as follows

https://github.com/flutter-webrtc/callkeep/blob/f49367b659cd00828091da8c0dcb4ab1746436ba/ios/Classes/CallKeep.m#L239-L245

~According to Apple's specification, aps is a required field, so can it be nil?~

in AWS SNS specification, aps is a required field, so can it be nil?

Note

Currently I am using AWS SNS for sending VoIP Pushes.

When I tried to send a payload without aps, I got the following result.

$ aws sns publish \
--target-arn arn:aws:sns:xxxxxxxxxxxx \
--message-attributes \
'{ "AWS.SNS.MOBILE.APNS.PUSH_TYPE":{"DataType":"String","StringValue":"voip"}}' \
--message '{"APNS_VOIP_SANDBOX":"{\"uuid\": \"xxxxx-xxxxx-xxxxx-xxxxx\",\"caller_id\": \"+8618612345678\",\"caller_name\": \"hello\",\"caller_id_type\": \"number\",\"has_video\": false}"}' \
--message-structure json \    

An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: Message Reason: Invalid notification for protocol APNS_VOIP_SANDBOX: aps key is expected in the json message
{
    "uuid": "xxxxx-xxxxx-xxxxx-xxxxx",
    "caller_id": "+8618612345678",
    "caller_name": "hello",
    "caller_id_type": "number",
    "has_video": false
}
oisikurumeronpan commented 3 years ago

If aps is not nil, the following will be printed to the console.

2021-11-30 19:32:07.416876+0900 Runner[54751:5587659] didReceiveIncomingPushWithPayload payload = PKPushTypeVoIP
2021-11-30 19:32:07.417073+0900 Runner[54751:5587659] Do not use the 'alert' format for push type PKPushTypeVoIP.
janhelwich commented 2 years ago

Got the same issue. Any solution to this?

oisikurumeronpan commented 2 years ago

According to the iOS specifications, the app will crash if you do not call displayIncomingCall inside the function that receives VoIP.

I fork and remove the non-null check and use it.

janhelwich commented 2 years ago

@oisikurumeronpan so you did remove that just locally? I do not see the change in the forked repository on Github.

oisikurumeronpan commented 2 years ago

@janhelwich Sorry for my late reply. I'm using this branch. This branch contains a fix for passing the content of the message to the Flutter runtime and a fix for aps.

janhelwich commented 2 years ago

Thanks. I found that for me it works without APS just fine. Needed to understand the differences between background and VoIP message handling and payload of messages. It works perfectly now.

AbdurrehmanSubhani commented 1 year ago

If aps is not nil, the following will be printed to the console.

2021-11-30 19:32:07.416876+0900 Runner[54751:5587659] didReceiveIncomingPushWithPayload payload = PKPushTypeVoIP
2021-11-30 19:32:07.417073+0900 Runner[54751:5587659] Do not use the 'alert' format for push type PKPushTypeVoIP.

Hey, im stuck in a similar situtaion, this is how it goes:

  1. When i receive a voip push the following logs are printed inside the xcode console:

Runner [49106:4285729] didReceiveIncomingPushWithPayload payload = PKPushTypeVoIP Runner[49106:4285729] Do not use the 'alert' format for push type PKPushTypeVoIP.

And after this the following error logs are displayed:

  1. Apps receving VoIP pushes must post an incoming call via Callkit in the same run loop as pushRegistry:didReceiveIncomingPushWithPayload:forType:[withCompletionHandler:]withoutdelay. Runner [42337:3707235] Assertion failure in -[PKPushRegistry _terminateAppIfThereAreUnhandledVoIPPushes], PKPushRegistry.m: 349 Runner [42337:37872351 Terminating app due to uncaught exception "NSInternalInconsistencyException', reason: 'Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push.'

Currently, im using this callkeep to get the Pushkit token which I use to sucessfully register with a 3rd party RTC service, what im trying to do is wake up the application through VoIP push to display a call when the app is in terminated/killed state, any help on how to acheive this would be much appreciated. Thanks!