首页 > 解决方案 > 为什么调用firebase函数时会出现FCM错误

问题描述

所以我通过AngularFire调用一个firebase函数,如下所示:

const response = await this.aFunctions.httpsCallable<void, ResponseType>('funcName')().toPromise();

这在部署到 firebase(托管)时有效,但在本地环境中(使用ionic serve),它会引发此错误:

ERROR Error: Uncaught (in promise): FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:8100/firebase-cloud-messaging-push-scope') with script ('http://localhost:8100/firebase-messaging-sw.js'): A bad HTTP response code (404) was received when fetching the script. (messaging/failed-service-worker-registration).
FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:8100/firebase-cloud-messaging-push-scope') with script ('http://localhost:8100/firebase-messaging-sw.js'): A bad HTTP response code (404) was received when fetching the script. (messaging/failed-service-worker-registration).

我在这个项目中没有以任何方式使用 FCM。你知道为什么会这样吗?

标签: angularfirebaseionic-frameworkgoogle-cloud-functionsangularfire

解决方案



推荐阅读