import * as admin from 'firebase-admin';
var serviceAccount = require('./keys/keyfile.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://test.firebaseio.com"
});
var registrationToken = "--some-key--";
var payload = {
notification: {
title: "$GOOG up 1.43% on the day",
body: "$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day."
},
data: {
stock: "GOOG",
open: "829.62",
close: "635.67"
}
};
function panelMessage(){
admin.messaging().sendToDevice(registrationToken, payload)
.then(function(response) {
// See the MessagingDevicesResponse reference documentation for
// the contents of response.
console.log("Successfully sent message:", response);
})
.catch(function(error) {
// console.log(serviceAccount);
var date = new Date();
console.log(date.toString());
console.log("Error sending message:", error);
});
}
üzerine asmak ve işe ama açısal-evrenselaçısal-evrensel | firebase-admin | kod: 'app/geçersiz-kimlik' | soket ben düğüm aracılığıyla bu kod çalıştırmasına
server.ts
dosyasında eklediğinizde .. o vermek
Zamanım kontrol .. hata şu (sorun olabilir birçok yerde okunur) ve hepsi senkronize edilir .. kimse sorunu ile bana yardımcı olabilir misiniz? Bu depoyu repositoryError sending message: { Error: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "socket hang up". at FirebaseAppError.Error (native) at FirebaseAppError.FirebaseError [as constructor] (D:\angular2MH\firebase - panel\panel\node_modules\firebase-admin\lib\utils\error.js:39:28) at new FirebaseAppError (D:\angular2MH\firebase - panel\panel\node_modules\firebase-admin\lib\utils\error.js:84:23) at D:\angular2MH\firebase - panel\panel\node_modules\firebase-admin\lib\firebase-app.js:119:23 at ZoneDelegate.invoke (D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:232:26) at Zone.run (D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:114:43) at D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:502:57 at ZoneDelegate.invokeTask (D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:265:35) at Zone.runTask (D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:154:47) at drainMicroTaskQueue (D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:401:35)
errorInfo: { code: 'app/invalid-credential', message: 'Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "socket hang up".' } }