【问题标题】:How to integrate FCM notification in VUE如何在 VUE 中集成 FCM 通知
【发布时间】:2018-06-11 09:50:15
【问题描述】:

我正在使用 webpack 在 Vue 中构建 Web 应用程序。目前我想在网络应用程序中集成 FCM(Firebase 云消息传递)通知以向用户发送通知。

我浏览了这个链接https://firebase.google.com/docs/web/setup?authuser=0,但我无法将它集成到 Vue 中

【问题讨论】:

标签: vue.js vuejs2 firebase-cloud-messaging


【解决方案1】:

三个步骤:

  1. npm i firebase

  2. 将以下内容添加到 main.ts..

    firebase.initializeApp({ apiKey: "YOUR KEY", authDomain: "...", databaseURL: "", projectId: "", storageBucket: "", messagingSenderId: "", appId: "" });let messaging!: firebase.messaging.Messaging; if (firebase.messaging.isSupported()) { messaging = firebase.messaging(); } export { messaging };

  3. 添加到公共文件夹 =>

    importScripts("https://www.gstatic.com/firebasejs/6.3.4/firebase-app.js"); importScripts("https://www.gstatic.com/firebasejs/6.3.4/firebase-messaging.js"); firebase.initializeApp({ messagingSenderId: "YOUR SENDER_ID" });const messaging = firebase.messaging();

就是这样!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-07
    • 2018-06-13
    • 2020-09-11
    • 1970-01-01
    • 2018-07-11
    • 2021-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多