我被困在 Firebase web codelab page 8 ,得到错误:
FirebaseError: Installations: Missing App configuration value: "appId" ...
我想我已按照说明进行操作。 http://localhost:5000/__/firebase/init.js不包含这样的字段:
if (typeof firebase === 'undefined') throw new Error('hosting/init-error: Firebase SDK not detected. You must include it before /__/firebase/init.js');
var firebaseConfig = {
"projectId": "friendlychat-310120",
"databaseURL": "https://friendlychat-310120.firebaseio.com",
"storageBucket": "friendlychat-310120.appspot.com",
"locationId": "europe-west3",
"apiKey": "AIza...vOXg",
"authDomain": "friendlychat-310120.firebaseapp.com",
"messagingSenderId": "480343738796"
};
if (firebaseConfig) {
firebase.initializeApp(firebaseConfig);
}
这不仅仅是错误。读取消息不起作用。
最佳答案
在 Issue 2287这是有背景的。提到的重大变化here :
If you are currently using FCM for web and want to upgrade to SDK 7.0.0 or later, you must enable the FCM Registration API for your project in the Google Cloud Console.
我这样做了:
此外,还需要:
Please also make sure that projectId, apiKey, appId and messagingSenderId are present in your app config.
如何实现这一目标的线索是 here :
Ok. Resolved. The
appId
is definitely not theprojectId
. And I have a hard time finding what it is, or how to get it. In order to get theappId
, you need to create an app registration (android, iOS or web) in the Firebase Console. ...
你可能会看到这个:
点击</>
图标,应用程序将被注册。这就够了。现在你的http://localhost:5000/__/firebase/init.js
托管配置对象还应包括 .appId
字段。
"appId": "1:4803...8796:web:400d...d209",
还有——最重要的是! - 我的网络 Codelab 应用程序现在可以运行了!
Firebase Web Codelab 会发生这种情况。希望他们添加了有关注册应用程序的必要性的提及(或者也许我只是错过了它?)。
关于javascript - Firebase Web 代码实验室 : missing app configuration value "appId",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60006057/