【发布时间】:2020-02-15 00:11:17
【问题描述】:
使用此代码在设备之间发送推送通知可以正常工作,但仅适用于 Android 和浏览器。
由于某种原因,这在 iOS 上不起作用,无论我使用的是 postData 对象还是字符串化的有效负载。任何想法为什么?
import { HttpClient } from '@angular/common/http';
public sendPushNotificationToToken(token: string, pnServerKey: string, message: string, userId: number): Observable<any> {
const firebaseUrl = "https://fcm.googleapis.com/fcm/send";
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'key=' + pnServerKey
})
};
const postData = {
'to': token,
'priority':'normal',
'notification': {
'title': message,
'message': message,
'userId': userId
},
};
return this.http.post(firebaseUrl, postData, httpOptions);
【问题讨论】:
标签: android ios angular firebase ionic4