Skip to content
Test Service Worker
JavaScript HTML
Branch: master
Clone or download
Latest commit 1ce0e71 Oct 22, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Bubble-Nebula.jpg add current time to input body Mar 16, 2017
Bubble-Nebula_big.jpg add Bubble-Nebula_big.jpg as example image in notification Jun 9, 2018
LICENSE Initial commit Feb 3, 2017
README.md Update README.md Oct 22, 2018
ScreenRecord.gif add ScreenRecord.gif Mar 18, 2017
app.js not force check HTTPS Jun 18, 2018
favicon.png add favicon Mar 16, 2017
firebase-messaging-sw.js copy data object Jun 9, 2018
firebase.js
index.html try to show notification image Jun 9, 2018

README.md

Test Firebase Cloud Messaging

You can test usage on page: https://peter-gribanov.github.io/serviceworker/

Firebase loses the image from the notification. You can fix the problem by specifying a image in data. And you must see this issue.

Send notification from HTTP client

POST /fcm/send HTTP/1.1
Host: fcm.googleapis.com
Authorization: key=AAAAaGQ_q2M:APA91bGCEOduj8HM6gP24w2LEnesqM2zkL_qx2PJUSBjjeGSdJhCrDoJf_WbT7wpQZrynHlESAoZ1VHX9Nro6W_tqpJ3Aw-A292SVe_4Ho7tJQCQxSezDCoJsnqXjoaouMYIwr34vZTs
Content-Type: application/json

{
  "data": {
    "title": "Bubble Nebula",
    "body": "It's found today at 21:00",
    "icon": "https://peter-gribanov.github.io/serviceworker/Bubble-Nebula.jpg",
    "image": "https://peter-gribanov.github.io/serviceworker/Bubble-Nebula_big.jpg",
    "click_action": "https://www.nasa.gov/feature/goddard/2016/hubble-sees-a-star-inflating-a-giant-bubble"
  }
  "to": "YOUR-TOKEN-ID"
}

Send notification by cURL

curl -d '
{
  "data": {
    "title": "Bubble Nebula",
    "body": "It`s found today at 21:00",
    "icon": "https://peter-gribanov.github.io/serviceworker/Bubble-Nebula.jpg",
    "image": "https://peter-gribanov.github.io/serviceworker/Bubble-Nebula_big.jpg",
    "click_action": "https://www.nasa.gov/feature/goddard/2016/hubble-sees-a-star-inflating-a-giant-bubble"
  }
  "to": "YOUR-TOKEN-ID"
}' \
    -H "Content-Type: application/json" \
    -H "Authorization: key=AAAAaGQ_q2M:APA91bGCEOduj8HM6gP24w2LEnesqM2zkL_qx2PJUSBjjeGSdJhCrDoJf_WbT7wpQZrynHlESAoZ1VHX9Nro6W_tqpJ3Aw-A292SVe_4Ho7tJQCQxSezDCoJsnqXjoaouMYIwr34vZTs" \
    -X POST "https://fcm.googleapis.com/fcm/send"

Warning

This application runs in GitHub Pages at address /serviceworker/ and this path cannot be changed. Therefore, the original library is copied to this application and the path to firebase-messaging-sw.js has been changed.

If you want to copy this application to your website and run it at the root path, you must use the original library and change path to the serviceworker.

You can’t perform that action at this time.