[英]Ionic: Send Push Notifications via firebase from device to device : Sending doesn't work from iOS
Sending push notifications from device to device works fine with this code, but only on Android and from a browser.使用此代码在设备之间发送推送通知可以正常工作,但仅适用于 Android 和浏览器。
For some reason this does not work on iOS, no matter if I use the postData object or the stringified payload.出于某种原因,这在 iOS 上不起作用,无论我是使用 postData 对象还是字符串化的有效负载。 Any ideas why?
任何想法为什么?
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);
The only way to solve this was to use "@ionic-native/http/ngx" instead of '@angular/common/http'.解决这个问题的唯一方法是使用“@ionic-native/http/ngx”而不是“@angular/common/http”。 Still don't see why the google Server refused to accept my payload.
仍然不明白为什么谷歌服务器拒绝接受我的有效载荷。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.