我刚刚为android和ios开发了一个视频呼叫应用程序,
我使用呼叫保持显示来电通知和fcm推送通知。在ios中,当应用程序处于前台时,它就能工作。但它并没有显示应用程序的背景。
在android系统中,它在前台和后台都能工作。
如何解决这个问题?
发布于 2022-10-27 11:31:16
您应该将这个包用于您的案例flutter_ios_voip_kit,这是链接:套套
发布于 2022-11-30 16:34:33
对我们来说,在iOS上被“调用”的唯一可靠方法是使用VoIP。您也可以将此与callkeep一起使用。然而,您将需要调用APN不是通过防火墙,而是必须实现自己的调用。
在我们的例子中,如下所示。这方面有几个很好的教程。例如:https://levelup.gitconnected.com/send-push-notification-through-apns-using-node-js-7427a01662a2
const key = fs.readFileSync(__dirname + "/AuthKey_XXXXXXXXXX.p8", 'utf8');
//"iat" should not be older than 1 hr from current time or will get rejected
const token = jwt.sign(
{
iss: "XXXXXXXXX", //"team ID" of your developer account
iat: Math.floor(new Date().getTime() / 1000)
},
key,
{
header: {
alg: "ES256",
kid: "XXXXXXXXXXX", //issuer key which is "key ID" of your p8 file
}
}
);
const options = {
':method': 'POST',
':scheme': 'https',
':path': '/3/device/' + deviceToken,
'apns-topic': 'XXX.ANEXAMPLE.ID.voip',//VERY IMPORTANT TO ADD THE .voip here
'apns-push-type': 'voip',
'apns-priority': '10',
'apns-expiration': '0',
'authorization': `bearer ${token}`
};
const uuid = crypto.randomUUID()
fullName = change.data().firstName + ' ' + change.data().lastName;
body = {
uuid: uuid,
caller_id: context.params.callerId,
caller_name: context.params.callerId,
has_video: true,
caller_id_type: "number"
};
strBody = JSON.stringify(body);
console.log("BODY: " + strBody);
let data = '';
const client = http2.connect('https://api.push.apple.com');
buff = Buffer.from(strBody);
req = client.request(options);
req.write(buff);
req.on('response', (headers) => {
for (const name in headers) {
console.log(`${name}: ${headers[name]}`)
}
})
.on('data', (chunk) => { data += chunk })
.on('end', () => {
console.log(`\n${data}`)
client.close()
})
.on('error', (err) => console.error(err));
req.end();
https://stackoverflow.com/questions/73773654
复制相似问题