문제가 해결되었습니다! 이전 버전이기 때문에.admin.messaging이 (가) 함수가 아닙니다.
나는 이미 최선을 다하지만 stackoverflow/google/firebase에 대한 해결책을 찾을 수 없습니다.
리눅스 서버에 node.js를 빌드하고 firebase에서 Cloud Messaging의 기능을 사용할 수 없습니다. 데이터베이스에 성공적으로 연결할 수 있습니다. 하지만 클라우드 메시징 서비스를 사용할 수 없습니다.
나는 코딩에 대해 매우 새로운 부분이 있으므로 기본적인 오류가 있으면 알려주십시오. Node.js를에
내 코드의 일부는 :
var admin = require("firebase-admin");
var serviceAccount_2 = require("/home/____________.json");
var app_V2 = admin.initializeApp({
credential: admin.credential.cert(serviceAccount_2),
databaseURL: "https://_______.firebaseio.com"
}, "myapp");
var payload = {
notification: {
title: "This is Title",
body: "This is Msg body"
}
};
var topic = "some_topic";
admin.messaging().sendToTopic(topic, payload)
.then(function(response) {
console.log("Successfully sent message:", response);
})
.catch(function(error) {
console.log("Error sending message:", error);
});
나는 많은 시간을 시도했지만 여전히 같은 오류가 있습니다.
FIREBASE WARNING: Exception was thrown by user callback. TypeError: admin.messaging is not a function
TypeError: admin.messaging is not a function
나는
https://firebase.google.com/docs/cloud-messaging/admin/send-messages#send_to_a_topic 에 동일한 코드를 사용하지만 여전히 같은 오류가 필요했습니다.
'npm version firebase'을 실행하여보고 내용을 알려 줄 수 있습니까? –
"package.json"을 빌드하지 않았습니다. "npm 버전 firebase"로 확인 할 수 없습니다. _ 하지만 내 버전은 [email protected]_ –