简体   繁体   中英

Call AWS Lambda function from React-Native

I have build a simple function in AWS Lambda which sends sms using Twilio service. I now want to call that function from my React-Native app. Do you have any suggestion to that?

There are two ways to invoke the AWS Lambda from your React-Native application

Direct invocation using AWS browser SDK

You can use lambda#invoke API to invoke your Lambda function from your React-Native app. Catch here is that you'll have to ship AWS credentials with your app. These credential will have permission to invoke the Lambda function.

Indirect onvocation using API Gateway

You can gate your Lambda function behind an API Gateway ( API Gateway + Lambda integration ). Then you can use standard JavaScript HTTP utilities to make REST calls to you API Gateway resource. This API Gateway resource will be responsible for invoking your Lambda function.

I prefer second method because API Gateway provides throttling support and we don't have to ship credentials with the app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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