【发布时间】:2021-07-28 16:07:49
【问题描述】:
我想在我的 iOS 应用程序不活动时向它发送 voip 推送,我尝试使用来自 this solution 的 apn module 但它对我不起作用。
我关注了关于 voip push here 的官方苹果文档,但从服务器发送它仍然存在一些问题。
我也尝试通过 AWS sns 服务发送它,但得到了正常推送通知等。
我做错了什么?
现在我的代码是:
这里我为 sns 项目做格式化
const formatVoipPushNotificationsToSend = (type, header, launchId, sender, to = '', device_token, token) => {
const headers = {
':method': 'POST',
'apns-topic': '************.voip', //application bundle ID
':scheme': 'https',
':path': `/3/device/${device_token}`,
'authorization': `bearer ${token}`,
'apns-push-type': 'voip',
};
const aps = {
alert: {
title: header,
body: 'text' || null
},
itemId: type,
from: sender || null,
to,
launchId: launchId || null,
'content-available': 1
};
return { aps, headers };
};
然后我在这里传递项目并将其发送到带有 sns 端点的应用程序。
const pushNotifications = (item, arn, userId) => {
const payload = JSON.stringify(item);
const snsMessage = {};
snsMessage[SNS_PAYLOAD_KEY] = payload;
const params = {
Message: JSON.stringify(snsMessage),
TargetArn: arn,
MessageStructure: 'json'
};
const eventBody = item.aps.itemId ? {
[EVENT_TYPES.PUSH_SEND]: item.aps.itemId
} : {};
AmplitudeService.logEvent(EVENT_TYPES.PUSH_SEND, userId, eventBody);
return snsClient.publish(params).promise();
};
【问题讨论】:
标签: ios node.js amazon-web-services apple-push-notifications voip