应用程序被杀时未收到IOS 13 VOIP推送通知

时间:2020-09-19 17:58:04

标签: cordova apple-push-notifications cordova-plugins voip ios13

我们有一个Cordova应用,该应用正在使用WebRTC进行视频聊天。
我们正在使用此插件来实现VOIP推送通知 https://github.com/mattkhaw/cordova-plugin-callkit
除此之外,我们正在使用AWS SNS为我们处理VOIP推送。
流程如何工作?

IOS Device Calee (User A)
1. When device opens the app, it registers on Apple servers and 
receives a VOIP Device Token
2. We call Amazon SNS to save the token and get the endpointARN for that token
3. We save the token in the database along with the user ID and endpointARN 
from AWS

Caller Side (User B)
1. User B wants to call User A
2. User B clicks the call button
3. A request it send to the server, which checks if a token exists for User A 
in the database.
4. If it exists, we call AWS SNS endpointARN so it will 
send a VOIP push to User A

当应用打开或在后台运行时,所有这些都可以正常工作。
该应用程序被终止(终止)时会出现问题。
当该应用被终止时,该应用将崩溃,这是我们收到的https://gist.github.com/AleksandarTokarev/74068feadd728a4bd1c672a024482af4日志。
我对日志的详细信息做了一些研究,看来原因是写在
https://developer.apple.com/forums/thread/124517

The exception code "0xbaadca11" indicates that your app was killled for failing to report a CallKit 
call in response to a PushKit notificaiton.  That should have been clear in the crash log,
but this particular requirement is implemented through multiple code paths and it looks like this 
one isn't as clear as the others.  For more details on the new requirement, take a look at:
https://developer.apple.com/videos/play/wwdc2019/707/

知道为什么会这样吗?当应用程序运行或在后台运行时,该插件可以正常运行。
我正在使用以下负载来调用AWS SNS

let voip_protocol_value = `{"aps" : { "alert": "New Incoming Call" },
 "data" : { "Caller": { "Username" : "${caller}", "ConnectionId": "${Random.id()}"}}}`
                let payload = {}
                payload[`APNS_VOIP`] = voip_protocol_value
                let params = {
                    'Message': JSON.stringify(payload),
                    'MessageAttributes': {
                        'AWS.SNS.MOBILE.APNS.PRIORITY': {
                            'DataType': 'String',
                            'StringValue': '10'
                        },
                        'AWS.SNS.MOBILE.APNS.PUSH_TYPE': {
                            'DataType': 'String',
                            'StringValue': 'voip'
                        },
                    },
                    'MessageStructure': 'json',
                    'TargetArn': user.endpointArn
                }

1 个答案:

答案 0 :(得分:0)

我设法通过以下方式修改插件来解决此问题:
https://github.com/luisbouca/cordova-plugin-callkit/compare/master...AleksandarTokarev:master

当应用被杀(终止)时,似乎没有调用init()函数,所以我的一个朋友帮我做了小小的重构,并将init()函数代码放在插件初始化中。

这意味着Pushkit尚未初始化(因为它在init()方法中)。

init()方法仍然存在,但是在用Java语言初始化时会调用它。

这可能与我们的Meteor Cordova应用程序以及应用程序本身中的初始化方式有关。

现在一切正常。