Tag: firebase

强制令牌刷新,但令牌仍然过期?

var app = angular.module('app', ['firebase']); const setAppCookie = () => firebase.auth().currentUser.getToken(true).then(token => { Cookies.set('token', token, { domain: window.location.hostname, expire: 1 / 24, path: '/', secure: true }); }); const unsetAppCookie = () => Cookies.remove('token', { domain: window.location.hostname, path: '/', }); app.factory("Auth", ["$firebaseAuth", function ($firebaseAuth) { return $firebaseAuth(); }]); app.controller("ctrlHead", ["$scope", "Auth", "$window", function ($scope, Auth, […]

如何发送通知给所有用户,除了android中的发件人使用节点js的firebase函数

我有一个firebase云function发送通知的主题。 问题是,它发送给所有用户,包括发件人,而我不希望它发送给发件人。 请不要提供订阅和取消订阅示例,因为我无法理解此解决scheme。 请帮忙? const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.pushNotification = functions.database.ref('/messages/{pushId}').onWrite( event => { console.log('Push notification event triggered'); var message1 = event.data.val(); if (!message1) { return; } var valueObject = message1.messageText; console.log('Push notification event triggered '+valueObject); const payload = { notification: { title:'Chat app', body: valueObject, }, }; const options […]

Firebase:firebase.messaging()不是一个函数

我正在尝试从FCM设置NodeJS Client Web App 。 我已经在服务器端设置了firebase-admin 。 设置客户端访问令牌时,我得到一个TypeError: firebase.messaging is not a function错误。 从其他解决scheme看来,似乎是不同FCM版本之间的兼容性错误,但仍然可以解决这个问题。 下面是我使用的HTML文件 <html> <head> <script src="https://www.gstatic.com/firebasejs/3.1.0/firebase.js"></script> </head> <body> <script> console.log(firebase); const messaging = firebase.messaging(); messaging.onTokenRefresh(function () { messaging.getToken() .then(function (refreshedToken) { console.log('Token refreshed.'); console.log(refreshedToken); // // Indicate that the new Instance ID token has not yet been sent to the // // […]

Firebasepipe理员SDK – DELETE响应不正确

我是新来的JavaScript(但不是新的编程)。 我正在使用NodeJs中的Firebase ADMIN SDK创build一个REST API。 如果资源存在,我能够成功执行DELETE请求。 但如果不存在(或者ID不正确),POSTMAN的响应仍然是成功的。 我想这个callback函数是不正确的。 当我实现GET /:id和PUT /:id时,我可能会看到相同的问题。 请帮忙。 // DELETE /api/billingPlans/:id // Delete a billing plan routes.delete('/:id', (req, res) => { var ref = admin.database().ref(firebaseNode); //Have also tried snapshot.exists() but similar problem occurs return ref.child(req.params.id).once('value', function(snapshot) { snapshot.ref.remove(function(error){ if(!error) res.status(200).json({"result" : "DELETE Success"}); else res.status(204).json({"error" : "Not found"}); }); });

在nodejs scrypt包中使用Firebase SCrypt params

我一直在为此奋斗一段时间,希望有人以前这样做,可以帮助我的方式。 为了将我们的用户身份validation从Firebase迁移到我们自己的服务器,我前往Firebase人员请求scrypt params。 现在我得到了这些参数,但我不知道如何映射到节点scrypt包( https://www.npmjs.com/package/scrypt )。 Firebase参数的格式如下: hash_config: { algorithm: SCRYPT, base64_signer_key: asdf1234 base64_salt_seperator: xxxx rounds: 123456 mem_cost: 098765 } 不知何故,这些应该映射到nodejs scrypt参数,但我找不到相似之处。 任何帮助将非常感激!

Firebase函数通知

我正尝试使用FCM服务发送简单的推送通知。 每当我的function被呼叫,我想收到一个通知,我希望我的手机振铃和振动。 我有两个问题: 当我收到通知时,我得到5个,而不是一个。 第二个问题是,如果我收到通知时手机的声音被激活,手机不会振动或振铃,但如果处于振动模式,则会在收到通知时振动。 任何想法如何解决这个问题? 谢谢! 'use strict' const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.sendNotification = functions.database.ref('/Alerts/{email_encoded}/{alert_id}').onWrite(event => { const email_encoded = event.params.email_encoded; const alert_id = event.params.alert_id; const deviceToken = admin.database().ref(`/Users/${email_encoded}/device_token`).once('value'); deviceToken.then(result => { const token_id = result.val(); const payload = { notification: { title: "Alert", body: "alert triggered", icon: "default", […]

使用Firebase身份validation和Express身份validation社交login?

我对Firebase颇为陌生,对Express也稍微有点新,而且我很难尝试使用Firebase提供的身份validationstream程。 我有这个路由,但每次我点击触发路由的button,我得到这个错误This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled. This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled. 我很确定networking存储已启用,但我很不确定如何修复location.protocol 。 […]

通过两个Firebase项目发送推送通知

我正在使用Admin SDK for node.js发送推送通知。 跟随教程,并用这个链接给出的例子初始化多个项目。 我需要知道如何使用node.js发送两个项目的推送通知。 在下面的方法中使用发送通知两个项目的基础上与默认项目的工作,但另一个项目得到如下错误 exports.send_test_mailer = function(req, res) { // Default project var registrationToken = ["f-vRsDouUFQ:APA91bGktVzu3WjKGqeXqdiYPI8B0lQXs34TkJS4p7LaMiFGfp5LdfB1ZjEhO3CY5ci92apqgt1hEJY0ml11C4hxYUaPfDl7PeDHhcmDGur0JUx5l3M2mLEj30epwRBWVsE4xMSTls4f"]; var payload = { notification: { title: "driver app", body: "driver app push notfications on the day." }, data: { score: "850", time: "2:45" } }; firebaseAdmin.messaging().sendToDevice(registrationToken, payload) .then(function(response) { console.log("Successfully sent message driver:", JSON.stringify(response)); }) […]

获取电子应用安装的实例ID

我正在开发一个基于电子的软件。 我想知道应用程序的每个安装的实例ID。 我想要类似于用于android的Firebase.instanceId。 类似的情况像firebase实例ID: 实例ID在以下情况除外: 应用程序删除实例ID 应用程序在新设备上恢复 用户卸载/重新安装应用程序 用户清除应用程序数据

如何让从Firebase上的Facebook身份validation生成的UID始终保持在我的应用程序?

在我的login屏幕上,用户通过Facebooklogin,并为当前login的用户生成唯一的UID。 然后,我将需要的信息存储在一个名为user的小孩的firebase中,然后用户中的每个小孩的forms是{uid:{name:blah,email:blah,phone:blah}} 将这些数据存储在Firebase之后,我想将页面redirect到我的form.ejs页面。 但是,我想要访问UID,以便我可以在应用程序中稍后查询当前用户的数据库。 我如何让这个UID在我的应用程序中保持不变,因为在我做location.href ='./form'的那一刻,我失去了对我保存的全局variablesUID的访问。 其次,我正在做所有这些保存到数据,并在.js文件中从客户端redirect。 我应该而是做这一切从服务器(app.js)? 我目前正在创build一个json对象,其中包含我需要从FB获取的数据,然后只需调用firebase并保存子项。 我应该创build一个ajax请求,并发送到我的服务器与发布请求,然后导航到form.js页面?