【发布时间】:2019-09-29 16:47:05
【问题描述】:
我正在使用 Angular httppost 模块从我的 nativescript 应用程序发送 firebase 通知,它有时会发送通知,有时它会返回请求缺少身份验证密钥(FCM 令牌)的错误。请参阅 FCM 文档的“身份验证”部分
如果应用程序在前台使用邮递员,它不会收到通知,但响应仍然成功,但如果应用程序在后台,或者我按下 android 上的主页按钮,它会收到通知 这里是邮递员的一瞥
sendtoken(id, detail) {
console.log("????????????????????????????????????????????????");
console.log(JSON.stringify(detail.firebase_token));
console.log(JSON.stringify(this.DataService.activeJob));
console.log("\n\n" + detail.JobID);
var job = this.DataService.activeJob.filter(f => detail.JobID === f.jobID)[0];
// + detail.amount + "\n Origin : " + job.jobOrigin + "\nDestination : " + job.jobDestination
var data = {
notification: {
"title": "JOB",
"text": "Your Firm was allocated a job of amount :",
"sound": "default"
},
"priority": "High",
"to": detail.firebase_token
};
// alert(JSON.stringify(data));
var ServerSettings =
{
serverpath: "https://fcm.googleapis.com/fcm/send"
};
this.headers.append("Authorization", "key=AAAA9wyBPKg:APA91bGI6dOOM42iTJNqO47xMC9QIkLHf738Sn1iVk0gbkZDND1fuP9zBW1A38DlhupDdvlsAZCJu1iNACjbVvtdZQd3ePXnq1xctwYQ3PCErchmyYMM4UvmWjeeNjn2X1IL9mgy5ioT");
this.headers.append("Content-Type", "application/json");
this.options.headers = this.headers;
//this.setHeaders();
console.log("\n\nSending to Server for Update :\n\n" + data);
let url = ServerSettings.serverpath;
return this.httpmodule.post(url,data, this.options);
}
与邮递员
{
"notification": {
"title": "JOB",
"text": "Your Firm was allocated 5",
"sound": "default"
},
"priority": "High",
"to": "dwu1TEW5sPM:APA91bEppyye2NCq5IAfnjJg95eTsnsPf4Vn3U8CLgvUjJnY7uAVs4ASZiu1RCuFKf7uzXYojAGzKQD8cflKRGvpiqhEymbhK-DB-LQi8MogWIyyIR_xOm64GIpbviWrDuVZt8Td6xZ2"
}
与邮递员联系
{
"multicast_id": 6341518491186981658,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1569773536386430%0a6c29b00a6c29b0"
}
]
}
【问题讨论】:
标签: angular nativescript