NextJS我可以整合Firebase Cloud Messaging

发布于 2025-02-12 10:05:23 字数 1170 浏览 0 评论 0原文

我会遇到此错误未接受的拒绝:FirebaseError:消息传递:此浏览器不支持使用Firebase SDK所需的API。 (消息传递/不支持的浏览器)。

这是我的配置:

firebase_config/config.js

// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getMessaging } from "firebase/messaging";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
  .....
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
// Initialize Firebase Cloud Messaging and get a reference to the service
const messaging = getMessaging(app);

export default app;

pages/firebase.js

    import React from "react";
    import app from "../firebase_config/firebase_config";
    const firebase = () => {
      return (
        <div>
          <h1>Firebase</h1>
        </div>
      );
    };
    
    export default firebase;

I am getting this error unhandledRejection: FirebaseError: Messaging: This browser doesn't support the API's required to use the Firebase SDK. (messaging/unsupported-browser).

Here is my configurations:

firebase_config/config.js

// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getMessaging } from "firebase/messaging";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
  .....
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
// Initialize Firebase Cloud Messaging and get a reference to the service
const messaging = getMessaging(app);

export default app;

pages/firebase.js

    import React from "react";
    import app from "../firebase_config/firebase_config";
    const firebase = () => {
      return (
        <div>
          <h1>Firebase</h1>
        </div>
      );
    };
    
    export default firebase;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文