Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cordova 应用程序被终止时未收到IOS 13 VOIP推送通知_Cordova_Apple Push Notifications_Cordova Plugins_Voip_Ios13 - Fatal编程技术网

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

Cordova 应用程序被终止时未收到IOS 13 VOIP推送通知,cordova,apple-push-notifications,cordova-plugins,voip,ios13,Cordova,Apple Push Notifications,Cordova Plugins,Voip,Ios13,我们有一个Cordova应用程序,它使用WebRTC进行视频聊天。 我们使用这个插件来实现VOIP推送通知 . 除此之外,我们还使用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 t

我们有一个Cordova应用程序,它使用WebRTC进行视频聊天。
我们使用这个插件来实现VOIP推送通知 .
除此之外,我们还使用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
当应用程序处于打开状态或处于后台时,所有这些都可以正常工作。
应用程序被终止(终止)时会出现问题。
当应用程序被杀死时,应用程序崩溃,下面是我们收到的日志。
我对日志细节做了一些研究,似乎原因写在

知道为什么会这样吗?当应用程序正在运行或在后台运行时,插件可以正常工作。
我使用以下有效载荷来调用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
                }

我通过以下方式修改插件来解决这个问题:

应用程序被终止(终止)时,似乎没有调用init()函数,所以我的一个朋友帮助我进行了小重构,并将init()函数代码放入插件初始化中

这意味着Pushkit没有初始化(因为它在init()方法中)

init()方法仍然存在,但在Javascript中初始化时会调用它

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

现在一切都好了

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
                }