HTTP.post al servidor FCM no funciona
Estoy usando Ionic 2 conMódulo nativo HTTP hacer una solicitud posterior al servidor FCM para notificaciones push. El código que estoy usando es:
HTTP.post(
"https://fcm.googleapis.com/fcm/send",
{
"notification": {
"title": "Notification title",
"body": "Notification body",
"sound": "default",
"click_action": "FCM_PLUGIN_ACTIVITY",
"icon": "fcm_push_icon"
},
"data": {
"hello": "This is a Firebase Cloud Messagin hbhj g Device Gr new v Message!",
},
"to": "device token",
},
{
Authorization: {
key: "AUTHORIZATION KEY HERE"
}
})
Me está dando un error:
Unimplemented console API: Unhandled Promise rejection:
Unimplemented console API: Error: Uncaught (in promise): [object Object]
Intenté la solicitud de publicación con Postman, funciona perfectamente bien entregando notificaciones push.
El código con Postman es:
POST /fcm/send HTTP/1.1
Host: fcm.googleapis.com
Content-Type: application/json
Authorization: key=Authorisation Key
Cache-Control: no-cache
Postman-Token: 446e253b-179a-d19b-21ea-82d9bb5d4e1c
{
"to": "Device Token",
"data": {
"hello": "This is a Firebase Cloud Messagin hbhj g Device Gr new v Message!",
}
"notification":{
"title":"Notification title",
"body":"Notification body",
"sound":"default",
"click_action":"FCM_PLUGIN_ACTIVITY",
"icon":"fcm_push_icon"
},
}
Preguntas:
No puedo agregarcontent-type
al encabezado en la solicitud de publicación HTTP, pero funciona con cartero.
Si trato de agregar unfunction(response) {
para obtener la respuesta del servidor, me da un error. La documentación para el mismo está enhttps://github.com/wymsee/cordova-HTTP