【问题标题】:Firebase web codelab: missing app configuration value "appId"Firebase 网络代码实验室:缺少应用配置值“appId”
【发布时间】:2020-01-31 14:44:28
【问题描述】:

我卡在Firebase web codelab page 8,收到错误:

FirebaseError:安装:缺少应用配置值:“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);
}

这不仅仅是错误。阅读消息不起作用。

【问题讨论】:

标签: javascript firebase firebase-cloud-messaging


【解决方案1】:

Issue 2287 中有这方面的背景。提到的重大更改here

如果您当前使用 FCM 网页版并希望升级到 SDK 7.0.0 或更高版本,则必须在 Google Cloud Console 中为您的项目启用 FCM Registration API

我做到了:

此外,还需要:

还请确保 projectId、apiKey、appId 和 messingsSenderId 存在于您的应用配置中。

如何达到这个目标的线索是here

好的。解决。 appId 绝对不是 projectId。我很难找到它是什么,或者如何得到它。为了获得appId,您需要在 Firebase 控制台中创建应用注册(Android、iOS 或 Web)。 ...

您可能会看到:

单击</> 图标,应用程序将被注册。这就够了。现在您的http://localhost:5000/__/firebase/init.js 托管配置对象也应该包含.appId 字段。

  "appId": "1:4803...8796:web:400d...d209",

还有——最重要的是! - 我的 web codelab 应用现在可以运行了!

Firebase 网络代码实验室会发生这种情况。希望他们提到需要注册应用程序(或者我可能只是错过了它?)。

【讨论】:

  • 我拥有所有这些,但仍然遇到同样的错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-18
  • 2021-11-25
  • 1970-01-01
相关资源
最近更新 更多