<!DOCTYPE html>
<html>
<head>
<title>FCM token</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
</head>
<body>
<script src="https://www.gstatic.com/firebasejs/3.6.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.6.1/firebase-messaging.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.6.3/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSygfhdfghdfgdudartfhjvxctfujcgxdf",
authDomain: "xcvg.firebaseapp.com",
databaseURL: "https://xcvg.firebaseio.com",
storageBucket: "xcvg.appspot.com",
messagingSenderId: "467764584564"
};
firebase.initializeApp(config);
const messaging = firebase.messaging();
messaging.requestPermission()
.then(function(){
console.log("GRANTED");
return messaging.getToken();
})
.then(function(token){
console.log(token);
})
.catch(function(err){
console.log('Error Occurred.')
})
</script>
</body>
</html>
我正在关注在网络浏览器中开始推送通知的官方指南。我对我的工作并不好
在控制台中,我得到令牌为&#39; null&#39;即使在授予通知权限后。
我该如何解决?