我尝试用fcm发送通知,但仍然收到错误:
该请求缺少身份验证密钥(FCM令牌)。请参阅https://firebase.google.com/docs/cloud-messaging/server上FCM文档的“身份验证”部分。
我在有角项目中与邮递员和http帖子一起尝试过。我有一个身份验证密钥(我的服务器密钥来自firebase),这就是为什么我无法理解问题的原因。
let headers = new Headers();
headers.append("Content-Type","application/json");
headers.append("Authorization","key=xxxx");
let Options = new RequestOptions({headers : headers , body :{
"registration_ids" : ["eO2Ht66UA6Y:APA91bFTKf0C701O4nXHYz7sdlh62pwG01X5apE8Ri_iEPkotonRE2vHzJQwXn2YjiJ7XtIYBT3pNK1VfnJ2zhjtd1k2kn2tqs4zoMl23DJd6XG1GFd0r9Jda5N-bO0B9gERi4xhtadj"],
"data" : {
"message" : "This is an FCM notification message!",
}}});
this.http.post('https://fcm.googleapis.com/fcm/send',Options).first().subscribe((result) => {
console.log(result);
}