javascript - Firebase Web 代码实验室 : missing app configuration value "appId"

标签 javascript firebase firebase-cloud-messaging

我被困在 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);
}

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

enter image description here

最佳答案

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.

我这样做了:

enter image description here

此外,还需要:

Please also make sure that projectId, apiKey, appId and messagingSenderId are present in your app config.

如何实现这一目标的线索是 here :

Ok. Resolved. The appId is definitely not the projectId. And I have a hard time finding what it is, or how to get it. In order to get the appId, you need to create an app registration (android, iOS or web) in the Firebase Console. ...

你可能会看到这个:

enter image description here

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

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

还有——最重要的是! - 我的网络 Codelab 应用程序现在可以运行了!

enter image description here

Firebase Web Codelab 会发生这种情况。希望他们添加了有关注册应用程序的必要性的提及(或者也许我只是错过了它?)。

关于javascript - Firebase Web 代码实验室 : missing app configuration value "appId",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60006057/

相关文章:

android - 添加firebase消息后 flutter 获得RuntimeException

javascript - EmberJS - 使用几个解决方案从外部调用组件方法(征集讨论)

javascript - 使用 javascript 从桌面播放音频

ios - Firebase监听点赞数的变化并将其显示在屏幕上

javascript - Dart-从字符串中提取日期(MM/DD/YYYY)

firebase - 如何根据用户属性、用户受众发送 Firebase Cloud Messaging 通知

javascript - FabricJS:将 SVG 添加到 Canvas 但在导出时不可见

javascript - 第二个 ajax 请求被忽略

javascript - Firebase 身份验证不适用于 Chrome

php - 如何向多个主题发送 FCM 推送通知