简体   繁体   English

从 React-Native 调用 AWS Lambda 函数

[英]Call AWS Lambda function from React-Native

I have build a simple function in AWS Lambda which sends sms using Twilio service.我在 AWS Lambda 中构建了一个简单的函数,它使用 Twilio 服务发送短信。 I now want to call that function from my React-Native app.我现在想从我的 React-Native 应用程序调用该函数。 Do you have any suggestion to that?你对此有何建议?

There are two ways to invoke the AWS Lambda from your React-Native application有两种方法可以从您的 React-Native 应用程序调用 AWS Lambda

Direct invocation using AWS browser SDK使用 AWS 浏览器 SDK 直接调用

You can use lambda#invoke API to invoke your Lambda function from your React-Native app.您可以使用lambda#invoke API 从您的 React-Native 应用程序调用您的 Lambda 函数。 Catch here is that you'll have to ship AWS credentials with your app.这里需要注意的是,您必须将 AWS 凭证与您的应用程序一起发送。 These credential will have permission to invoke the Lambda function.这些凭据将有权调用 Lambda 函数。

Indirect onvocation using API Gateway使用 API 网关的间接调用

You can gate your Lambda function behind an API Gateway ( API Gateway + Lambda integration ).您可以在 API 网关( API 网关 + Lambda 集成)后面控制您的 Lambda 函数。 Then you can use standard JavaScript HTTP utilities to make REST calls to you API Gateway resource.然后,您可以使用标准的 JavaScript HTTP 实用程序对您的 API 网关资源进行 REST 调用。 This API Gateway resource will be responsible for invoking your Lambda function.此 API 网关资源将负责调用您的 Lambda 函数。

I prefer second method because API Gateway provides throttling support and we don't have to ship credentials with the app.我更喜欢第二种方法,因为 API 网关提供节流支持,而且我们不必随应用程序一起提供凭据。

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

相关问题 React-native 应用程序:navigation.navigate 不是 function - React-native app: navigation.navigate is not a function 从用 Node.js 编写的 AWS Lambda 函数调用 Python boto3 库 - Call Python boto3 library from AWS Lambda function written in Node.js Firebase 是 react-native 后端 - Firebase are react-native backend AWS Lambda - 调用另一个 lambda 函数的方法 - AWS Lambda - Invoke a method of another lambda function React-Native GoogleSignin.SIGN_IN_CANCELLED - React-Native GoogleSignin.SIGN_IN_CANCELLED 上传 react-native 张图片到 S3 - Uploading react-native images to S3 使用 AWS Amplify 从 React Native 上传到 S3 - Upload to S3 from React Native with AWS Amplify React-native 与 Firebase FCM 不工作 - React-native with Firebase FCM not working 如何在 React-Native 中使用 Z9017AFDB2E0254E2BB692ZA8 将 LocalScreenShare 曲目从 IOS 发布到 Web 浏览器 - How to publish LocalScreenShare tracks from IOS to Web browser in React-Native using Twilio 建议使用@vitalets/google-translate-api 之类的库或直接从 react-native 翻译? - It is advisable using libraries like @vitalets/google-translate-api or translate directly from react-native?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM