Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Unable to send notification to chrome with data.

Đang mở
#131 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
18/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
firebase, javascript, python
Lĩnh vực
backend, web-dev

Hướng nghiên cứu

Start by comparing the manifest.json sender ID, the sw.js push handler, and the main.js subscription flow with the pywebpush calls shown in the report. Review the linked VAPID and pywebpush references alongside the FCM error response. Done means the supported credential and payload path for delivering data to Chrome is documented or reproduced with a focused test.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I'm trying to send push notification that contains some data to chrome using FCM.

I'm using firebase console and credentials copied from it to generate a push notification
image

The chrome code looks like this:
manifest.json:

{
  "name": "PyChat Push Notification",
  "short_name": "PyPush",
  "start_url": "/",
  "display": "standalone",
  "gcm_sender_id": "620421656154"
}

sw.js:

self.addEventListener('push', (e: any) => e.waitUntil(getPlayBack(e)));

main.js:

await webpackServiceWorker.register( {scope: '/'}) ;
let subscription = await this.serviceWorkerRegistration.pushManager.subscribe({userVisibleOnly: true});
sendToServer( subscription.toJSON())

I can successfully send a push notification W/O any data using

from pywebpush import webpush, WebPusher
WebPusher(registration_id_from_browser).send("asd", gcm_key=server_key_from_image_above)

WIth the current method, in the data field in event is null on service worker. If I understood correctly this data needs to be encrypted using VAPID otherwise firebase replaces it with null. So my attempt looks like this:

vapid_data = {'privateKey': 'COPIED_PRIVATE_KEY_FROM_FIREBASE_MAGE_ABOVE', 'publicKey': 'COPIED_PUBLIC_KEY_FROM_IMAGE_ABOVE'}
webpush(
    registration_id_from_the_browser,
    'Your Push Payload Text',
    vapid_private_key=vapid_data['privateKey'],
    vapid_claims={"sub": "mailto:[email protected]", 'aud': 'https://fcm.googleapis.com'}
 )

But i'm getting

Response body:the key in the authorization header does not correspond to the sender ID used to subscribe this user. Please ensure you are using the correct sender ID and server Key from the Firebase console.

I also tried to put server_key copied from firebase console (the image) but the error is still the same.

I feel kinda confused at the end of the day since I read a lot of topics like this and this and this and this and this and this and also using PyFCM library and nothing seems to work.

Could someone please clarify:

  • is FCM and GCM are the same?
  • If google announced that GCM are no longer supported a few years ago, why my FCM messages still work w/o data, as I use gcm_sender_id in manifest.json.
  • If vapid is required to send push messages, Should I copy private key form FCM console or generate by itself?
  • If FCM server_key is no required to send push notification, does this means that everyone who knows user_subscription_id can send a push notification to the end user via my FCM account?
  • How can I send notification with data to chrome device. Is FCM the only option? Also I would not like use google libraries on the client to get push notifications since they are really heavy.
Ngôn ngữ chính
Python
Star
380
Fork
61
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của web-push-libs/pywebpush

Tất cả issue của web-push-libs/pywebpush

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.