gpt4 book ai didi

firebase - 什么是在 Flutter 中使用 Firebase Cloud Functions 的方法。

转载 作者:IT王子 更新时间:2023-10-29 06:48:25 24 4
gpt4 key购买 nike

我一直在搜索如何使用 flutter 应用程序实现 firebase 功能。似乎还没有可用的 SDK。我还尝试将 gradle 依赖项 implementation 'com.google.firebase:firebase-functions:15.0.0' 添加到我的 app/build.gradle 但这会导致构建错误。

有人做过有效的实现吗?我找不到任何关于如何处理凭据和数据传输以构建我自己的 firebase 函数调用的文档。

我已经大致概述了我认为这是如何工作的,但可能与基础相去甚远。

Future<dynamic> updateProfile(String uid, AccountMasterViewModel avm) async {

Uri uri = Uri.parse(finalizeProfileFunctionURL);
var httpClient = new HttpClient();
String _result = '';

try {
return await httpClient
.postUrl(uri)
.then((HttpClientRequest request) {
return request.close();
// authentication??
// Fields and data??
})
.then((HttpClientResponse response) async {
print(response.transform(new Utf8Codec().decoder).join());
if (response.statusCode == HttpStatus.OK) {
String json = await response.transform(new Utf8Codec().decoder).join();
_result = jsonDecode(json);
// Do some work
return json;
}
else {
return ':\nHttp status ${response.statusCode}';
}
});
}
catch (exception) {
return 'Failed ' + exception.toString();
}
}

我希望能够发送一个对象,例如

{
accountID: src.accountID,
accountName: src.name,
accountImg: src.image
}

然后处理响应。但正如我所说,我找不到任何有关如何执行此操作的工作示例或教程。执行此客户端大小并直接与数据库对话是相当简单的,但是,需要对客户端隐藏验证和数据组件,因此云功能是我想要执行此操作的方式。

最佳答案

是的,这里有一个 cloud_function 包:https://pub.dartlang.org/packages/cloud_function .

以便调用您可以调用的函数

CloudFunctions.instance.call(
functionName: 'yourCloudFunction',
parameters: <String, dynamic>{
'param1': 'this is just a test',
'param2': 'hi there',
},
);

关于firebase - 什么是在 Flutter 中使用 Firebase Cloud Functions 的方法。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50109597/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com