[英]Uncaught TypeError: firebase.messaging is not a function
Here is my code:这是我的代码:
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "<from firebase>",
authDomain: "<from firebase>",
databaseURL: "<from firebase>",
projectId: "<from firebase>",
storageBucket: "",
messagingSenderId: "<from firebase>",
appId: "<from firebase>"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
// [START get_messaging_object]
// Retrieve Firebase Messaging object.
const messaging = firebase.messaging();
</script>
This line firebase.messaging();
这一行
firebase.messaging();
throws:抛出:
Uncaught TypeError: firebase.messaging is not a function at
Uncaught TypeError: firebase.messaging is not a function at
Noted that the result of console.log(firebase)
is:注意到
console.log(firebase)
的结果是:
Any idea what's the problem?知道有什么问题吗?
It looks like you didn't follow the basic integration steps from the documentation.看起来您没有遵循文档中的基本集成步骤。 There is an include for messaging:
有一个用于消息传递的包含:
<script src="https://www.gstatic.com/firebasejs/7.7.0/firebase-messaging.js"></script>
You must included import '@firebase/messaging' for it to work.您必须包含 import '@firebase/messaging' 才能使其工作。 So it's supposed to look like this:
所以它应该是这样的:
import * as firebase from 'firebase/app';
import '@firebase/messaging';
Original answerd: TypeError: firebase.messaging is not a function in node.js原回答: TypeError: firebase.messaging is not a function in node.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.