如何從我的API函數獲取回調,以便將其轉發給我的API? 當我使用callback()
時,我只是JavaScript的新手。它是 顯示callback()
不是一個函數。我的APN功能可以從我的Node.js應用程序發送通知,但回調沒有顯示參考
function sendiosNotification(notification,callback){
if(!notification.data.to){
return callback({error : false, message : "receiver's deviceid is not available. could not send notificaion"});
}
var client = new apns.Provider({
cert:"./cert/cert.pem",
key:"./cert/key.pem",
production: true,
});
var notifi = new apns.Notification();
notifi.topic = "---"
notifi.alert = notification.data.message;
notifi.title = notification.data.username;
device_token = notification.data.to;
client.send(notifi,device_token).then(result =>{
console.log(result);
callback()
});
}
data
來自我的API。我可以成功向我的設備發送通知,但該功能沒有發送任何迴應。
在我的API中使用sendios
函數。
sendiosNotification({ data : data })
如何使用響應或回調將通知響應發送回API?
你是如何在回調傳遞給sendiosNotification功能? – 2K01B5
Passon回調。這只是代碼我有,如果你可以幫我 –