Step #11 Error: "Unable to get messaging token. FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope..."

Đang mở
#575 0 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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
firebase, javascript
Lĩnh vực
web-dev

Hướng nghiên cứu

Tái hiện Bước 11 cục bộ trong Chrome và kiểm tra việc đăng ký web-start\public\firebase-messaging-sw.js, tệp này có thể truy cập tại /firebase-messaging-sw.js. So sánh thiết lập Firebase Messaging của codelab với FirebaseError đã được báo cáo và xác minh rằng service worker mặc định được đăng ký và console in ra token thiết bị FCM.

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

Mô tả

codelab
[REQUIRED] Codelab info

https://codelabs.developers.google.com/codelabs/firebase-web/#10

I encountered this problem on "Step 11. Show notifications"

[REQUIRED] Project setup

As instructed, I've created firebase-messaging-sw.js in web-start\public. Ie. Loading this works for me:
http://localhost:5000/firebase-messaging-sw.js

I am working on localhost in Chrome Version 87.0.4280.88 (Official Build) (64-bit).

[REQUIRED] Describe the problem

On Step 11, I am currently on the step: "Get your device token." But after I refresh my browser (Chrome) and allow notifications, I am getting this error in the console:

image

Per the codelab tutorial, after clicking "Allow" (notifications in the browser), I was expecting in my console:
4. Open the JavaScript console of your browser. You should see the following message: Got FCM device token: cWL6w:APA91bHP...4jDPL_A-wPP06GJp1OuekTaTZI5K2Tu

What I've tried:

I saw there was a previous closed issue: https://github.com/firebase/codelab-friendlychat-web/issues/208

I've tried copying my firebaseConfig var and manually initializing it again but it didn't work for me. Ie. This didn't work for me:

image

PS. Obviously, I went to my Firebase project console and copied over my actual project parameters. Ie. The javascript object given under:

image

The only other change was in the codelab, in firebase-messaging-sw.js the firebase versions were hardcoded to 6.0.4 but I went ahead and updated those to 8.2.2.

[Optional] Suggested fix

Unsure. Please help. Thank you! Everything else in the codelab was terrific so far. I know I'm a decade late to Firebase but this is amazing! Thank you for putting it together! 🙏🙏🙏

Ngôn ngữ chính
JavaScript
Star
1.9k
Fork
1.8k
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

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 firebase/codelab-friendlychat-web

Tất cả issue của firebase/codelab-friendlychat-web

Issue tương tự

Thêm issue về JavaScript

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.