Я пытаюсь отправить push-уведомление от веб-клиента аналогичным клиентам.Мне удалось реализовать на принимающей стороне, однако я не могу отправить из-за следующей ошибки:
Реализация учетных данных, предоставленная для initializeApp () через свойство "учетные данные", не смогла получить действительный GoogleТокен доступа OAuth2 со следующей ошибкой: «Ошибка при получении токена доступа: Ошибка при выполнении запроса: Не удалось получить. Код ошибки: не определено».
Мой файл инициализации firebase:
import firebase from "firebase";
var firebaseConfig = {
apiKey: "AIzaSyBhQV8zHeo7piFalXcA14v6hV*****",
authDomain: "*****-demo-a82ca.firebaseapp.com",
databaseURL: "https://*****-demo-a82ca.firebaseio.com",
projectId: "*****demo-a82ca",
storageBucket: "",
messagingSenderId: "52526034576",
appId: "1:52526034576:web:7b271318a*****"
};
// Initialize Firebase
const firebaseApp = firebase.initializeApp(firebaseConfig);
export default firebaseApp.firestore();
export const firebaseMessaging = firebaseApp.messaging()
firebaseMessaging.initializeApp(firebaseConfig);
И js-файл выполняет отправку:
import { firebaseMessaging } from "@/firebase/init";
sendNotification() {
this.broadcastingAnnouncement = true;
console.log("Selected audience: ", this.selectedAudience);
var registrationToken =
"ezdWAWsKo48:APA91bF************"; //Client to receive the notification
var message = {
data: {
title: "Hello World",
body: "Test message"
},
token: registrationToken
};
firebaseMessaging
.messaging()
.send(message)
.then(response => {
// Response is a message ID string.
console.log("Successfully sent notification:", response);
})
.catch(error => {
console.log("Error sending message:", error);
});
}
В чем может быть моя проблема здесь?(Я подтвердил, что мой ключ API правильный)