简体   繁体   English

如何在离子中实现Firebase云功能?

[英]How to implement a firebase cloud functions in ionic?

I want to implement a function with firebase functions, but the problem is that in the firebase panel it is never reflected that something is being done. 我想用firebase函数实现一个函数,但是问题是在firebase面板中它从未反映出正在执行某些操作。

this is my functions code, the idea is get all data from a specific document with specific id. 这是我的函数代码,其想法是从具有特定ID的特定文档中获取所有数据。

 exports.identifyusers=functions.https.onRequest((req, res) => { var db = admin.firestore(); const key=req.query.key; return db.collection("usuariosdinny").doc(key).get().then(snapshot => { console.log("Correcto") }).catch(reason => { res.send(reason) }) }); 

this is the part when i invoke the function:(this part is a auth process that is correct the user i get the id and going to send this id to the function) 这是我调用函数时的部分:(这部分是一个身份验证过程,对用户我是ID并将其发送给函数的用户来说是正确的)

 this.afAuth.auth.signInWithEmailAndPassword(userst.email,userst.password) .then(res=> { console.log(this.afAuth.auth.currentUser.uid); var tipo= firebase.functions().httpsCallable('identifyusers').arguments(this.afAuth.auth.currentUser.uid); console.log(tipo); if(tipo=="Cliente Dinny") { console.log("Es un cliente"); } else{ console.log("No tiene permiso para") } } //this.navCtrl.push(TabsControllerPage)&& loader.dismiss()) ).catch(reject =>alert.present() && loader.dismiss()); }).catch(reject=>loader.dismiss()); 

thanks for your help. 谢谢你的帮助。

Your client code is attempting to call a "callable" function: 您的客户代码正在尝试调用“可调用”函数:

firebase.functions().httpsCallable('identifyusers')

But your function is defined as an HTTP type function: 但是您的函数定义为HTTP类型的函数:

exports.identifyusers=functions.https.onRequest(...)

If you want to invoke a callable function, you will have to write a callable function. 如果要调用可调用函数,则必须编写一个可调用函数。 Read the documentation for callable functions to understand how to do that. 阅读有关可调用函数的文档,以了解如何执行此操作。

exports.identifyusers = functions.https.onCall(...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM