Web上没有生成FCM令牌

时间:2018-04-06 05:42:00

标签: javascript firebase firebase-cloud-messaging frontend

令牌不在网上生成........................................ .................................................. .................................

   <!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
heloooo


</body>
</html>

<script src="https://www.gstatic.com/firebasejs/4.12.1/firebase.js"></script>
<script>
  // Initialize Firebase
  var config = {
    apiKey: "",
    authDomain: "",
    databaseURL: "",
    projectId: "",
    storageBucket: "",
    messagingSenderId: ""
  };
  firebase.initializeApp(config);

const messaging=firebase.messaging();
messaging.requestPermission()
.then(function() {
console.log('Have permission');
return messaging.getToken();
})
.then(function(token){
console.log(this.token);
})

.catch(function(err){
console.log('Error occured.');
})
</script>

这是我的代码抱歉我无法完全显示我的fcm启动代码

error on my console
hello.html:29 Have permission
hello.html:33 null
hello.html:34 undefined

1 个答案:

答案 0 :(得分:0)

初始化时需要提供API密钥

相关问题