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
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)。