【发布时间】:2020-11-20 06:45:20
【问题描述】:
我制作了一个 Flutter 应用程序,每次更新我的数据库时都会收到通知。
使用 Angular 单独处理数据库。但是,当我从 Angular 向 Firebase 发出 POST 请求以发送通知时,我在记录响应时收到以下错误:
代码如下:
export class AppComponent {
constructor(private CustomService: CustomService) {}
onButtonClick() {
this.CustomService.pushNotification().subscribe((Response) => {
console.log(Response);
});
}
}
这是服务代码:
export class CustomService{
// I also do not know if this is the correct format to send
myNotification: Object = {
notification: {
title: 'Angualr Notification',
body: 'Displayed from Angular: App is in backgroud or closed!',
},
data: {
title: 'Angular Notification',
body: 'Displayed From Angular: App is open',
click_action: 'FLUTTER_NOTIFICATION_CLICK',
},
topic: 'all_users',
};
FirebaseProjectURL: string "https://console.firebase.google.com/project/dummy-project-123/";
pushNotification(): Observable<Object> {
return this.http.post<Object>(this.FirebaseProjectURL, this.myNotification);
}
}
【问题讨论】:
标签: angular typescript