Firebase web notifications without error but witho

2019-08-28 01:41发布

问题:

I subscribe a Firebase Project to send notifications via Web.

I prepare an HTML page to allow the notifications and get the Instance ID Token. Once get this I.I. Token, I use "REST Console" to make a POST request to send my first notification.

Here above more information about the request:

REQUEST URI: https://fcm.googleapis.com/fcm/send
REQUEST METHOD: POST
CONTENT-TYPE: application/json
AUTHORIZATION HEADER: key=AAAAlBHBaYo:APA91bEeEse5l9Gxhu39N...
PAYLOAD: { "notification": {
    "title": "Background Message Title",
    "body": "Background message body",
    "click_action" : "https://www.google.com"
  },
"to":"cNMqR2k1Gcs:APA91bFbK..."
}

Let me explain some key:
- Authorization header: the key is the Server Key in the Firebase Console.
- "to" field in the JSON is the Instance ID Token appeared in the HTML page where I asked the permission to use notifications.

When I do the POST Request I get this response:

{
    "multicast_id": 5398627221409567591,
    "success": 1,
    "failure": 0,
    "canonical_ids": 0,
    "results": [{
        "message_id": "0:1527760006779230%e609af1cf9fd7ecd"
    }]
}

I suppose that everyting goes right BUT I didn't receive any notification. Chrome shows nothing :(

Where do I wrong?

Thanks in advance.

回答1:

Take a look at chrome://gcm-internals, do you see a message being received in there?