我有一个由AWS上的lambda触发的SNS生成iOS推送通知,工作正常,但问题是声音没有发生......
const sns = new AWS.SNS();
var payload = {
default: ' World23',
APNS: {
aps: {
alert: 'tkt',
sound: 'default',
badge: 1
}
}
};
// first have to stringify the inner APNS object...
payload.APNS = JSON.stringify(payload.APNS);
// then have to stringify the entire message payload
payload = JSON.stringify(payload);
var params = {
Message:payload,
MessageStructure: 'json',
Subject: event.body.subject,
TargetArn:TargetArn
};
sns.publish(params, function(err,data){
if(err) {
console.error('error publishing to SNS',err);
context.fail(err);
} else {
console.info('message published to SNS',data);
done(null, data);
}
});
我的有效载荷有什么问题?声音和徽章没有设定。 干杯...
答案 0 :(得分:0)
身体的格式需要一些调整,环境也是“沙盒”,必须改变prod推送通知“APNS”......
const sns = new AWS.SNS();
var payload = {
default: notifMessage,
'APNS_SANDBOX': {
'aps': {
'alert': notifMessage,
'sound': 'default',
'badge': 1
}
},
// first have to stringify the inner APNS object...
payload.APNS_SANDBOX = JSON.stringify(payload.APNS_SANDBOX);
// then have to stringify the entire message payload
payload = JSON.stringify(payload);
var params = {
// Message: event.body.message,
Message:payload,
MessageStructure: 'json',
Subject: event.body.subject,
TargetArn:TargetArn
};
console.log('params:: ', payload);
sns.publish(params, function(err,data){
if(err) {
console.error('error publishing to SNS',err);
context.fail(err);
} else {
console.info('message published to SNS',data);
done(null, data);
}
});