Javascript 尝试使用AngularFire';s云消息传递模块抛出缺少的应用程序配置值

Javascript 尝试使用AngularFire';s云消息传递模块抛出缺少的应用程序配置值,javascript,angular,firebase-cloud-messaging,angularfire,Javascript,Angular,Firebase Cloud Messaging,Angularfire,我正在AngularFire2上设置Firebase云消息,以接收和发送通知。但是,当尝试获取用户的当前令牌时,应用程序返回一个错误 我已经创建了“firebase messaging sw.js”和“manifest.json”文件来注册服务工作者,并正确添加了所有内容,但没有成功 我订阅可观测数据的组件 导出类HomeComponent实现OnInit{ 建造师( 私人afMessaging:AngularFireMessaging, 私人afStore:AngularFirestore,

我正在AngularFire2上设置Firebase云消息,以接收和发送通知。但是,当尝试获取用户的当前令牌时,应用程序返回一个错误

我已经创建了“firebase messaging sw.js”和“manifest.json”文件来注册服务工作者,并正确添加了所有内容,但没有成功

我订阅可观测数据的组件

导出类HomeComponent实现OnInit{
建造师(
私人afMessaging:AngularFireMessaging,
私人afStore:AngularFirestore,
私人afAuth:AngularFireAuth,
) {}
恩戈尼尼特(){
this.afAuth.user.pipe(
排气图(
用户=>{
返回此.afMessaging.getToken.pipe(
水龙头(
令牌=>{
console.log(令牌);
此.afStore.collection('users').doc(user.uid).update({
fcmToken:令牌
});
}
)
);
}
)
).subscribe();
此为.afMessaging.messages
.subscribe((消息)=>{console.log(消息);});
}
}
服务人员:

  // Give the service worker access to Firebase Messaging.
  // Note that you can only use Firebase Messaging here, other Firebase libraries
// are not available in the service worker.
importScripts("https://www.gstatic.com/firebasejs/6.3.4/firebase-app.js");
importScripts("https://www.gstatic.com/firebasejs/6.3.4/firebase-messaging.js");

// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({
  messagingSenderId: "231973795174"
});

// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = firebase.messaging();

messaging.setBackgroundMessageHandler(function(payload) {
  console.log(
    "[firebase-messaging-sw.js] Received background message ",
    payload
  );
  // Customize notification here
  const notificationTitle = "Background Message Title";
  const notificationOptions = {
    body: "Background Message body.",
    icon: "/firebase-logo.png"
  };

  return self.registration.showNotification(
    notificationTitle,
    notificationOptions
  );
});

舱单

{
  "name": "App",
  "gcm_sender_id": "103953800507"
}
Angular.json

"assets": [
    "src/favicon.ico",
    "src/assets",
    "src/firebase-messaging-sw.js",
    "src/manifest.json"
 ],
我得到的错误详细如下:

未捕获(承诺中):FirebaseError:安装:缺少应用程序配置值。(安装/缺少应用程序配置值)。 FirebaseError:安装:缺少应用程序配置值。(安装/缺少应用程序配置值)。 在extractAppConfig(index.esm.js:89) 在Object.factoryMethod[作为安装](index.esm.js:1110) 在FirebaseAppImpl.push../node_modules/@firebase/app/dist/index.cjs.FirebaseAppImpl.\u getService(index.cjs.js:191) 在FirebaseAppImpl.FirebaseAppImpl。[作为安装](index.cjs.js:458) 在index.esm.js:415处 步骤(tslib.es6.js:99) 在Object.next(tslib.es6.js:80) 在tslib.es6.js:73 在新的ZoneAwarePromise(zone evergreen.js:876) at__等待者(tslib.es6.js:69) at resolvePromise(zone evergreen.js:797) 常青区。js:707 常绿区,js:723 在ZoneDelegate.invoke(zone evergreen.js:359) 在Object.onInvoke(core.js:39698) 在ZoneDelegate.invoke(zone everyver.js:358) 在Zone.run(Zone evergreen.js:124) 常青区。js:855 在ZoneDelegate.invokeTask(zone everyver.js:391) 在Object.onInvokeTask(core.js:39679)


您需要在initializeApp呼叫中填写所有必需的详细信息:

const firebaseConfig = {
apiKey: "",
authDomain: "<your app>.firebaseapp.com",
databaseURL: "https://<your app>.firebaseio.com",
projectId: "<your app>",
storageBucket: "<your app>.appspot.com",
messagingSenderId: "<your sender id>",
appId: "<your app id>",
measurementId: "<your measurement id>"
  };
const firebaseConfig={
apiKey:“,
authDomain:“.firebaseapp.com”,
数据库URL:“https://.firebaseio.com",
投射:“,
storageBucket:“.appspot.com”,
messagingSenderId:“”,
appId:“”,
计量单位:“
};
您可以从Firebase控制台获取这些详细信息