我正在尝试通过Firebase函数和Firbase Cloud Messeaning创建一个oke函数。但是我的要求很差400个无效的参数错误。我在我的sendpoke.js文件中添加了日志行,以检查问题所在。我遇到的问题是sendby,而前哨是无效的。但是我敢肯定,sendto或sentby not null。你能帮助我吗? 这是我的sendpoke.js文件

问题描述 投票:0回答:1
Future<void> sendPokeNotification(String sentTo) async { try { // call callable function final HttpsCallable callable = FirebaseFunctions.instance.httpsCallable('sendPoke'); print('senTo '+sentTo);//this is not null final currentUser = FirebaseAuth.instance.currentUser; if (currentUser == null) { throw Exception("The user did not login."); } final idToken = await currentUser.getIdToken(); print("UserID Token: $idToken"); // send data and give respond final response = await callable.call(<String, dynamic>{ "sentTo": sentTo, // reciever UID "message": 'Hi, i poked you!', // message content }); print('Function respond: ${response.data}'); } catch (e) { print('Send Poke Error: $e'); } }

sentBy
是发件人的UID,

sentTo

是Reciever设备令牌。 另外,我以这种方式将sendpoke函数添加到idnex.js文件:
const sendPoke = require("./functions/utilities/pokeAndNotifications/sendPoke");
exports.sendPoke = functions.https.onCall(sendPoke);

	
您从颤音代码中调用了所谓的cloud cloud函数
,但是您的javascript实现了

规范的https cloud函数
。两种类型无法互操作。
您要么必须在JavaScript中实现可呼出的云功能,要么使用常规的HTTP(S)调用(而不是Flutter Code中的firapsae SDK的the wrapper)。
javascript flutter google-cloud-functions firebase-cloud-messaging
1个回答
0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.