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?
AWS Amplify enables React Native developers to create high-quality applications on a flexible, scalable, and reliable serverless backend.
You will want to select “New API'” here, enter in an “API name” and click “Create API”. Under the “Actions” menu please select “Create Method”. Please select “ANY” here and click on the tick to confirm. Make sure you select “Lambda Function” here and type in your “Lambda Function” name, in this case “mediumtutorial”.
The React app is rendered with a Lambda function. The CloudFront distribution is configured to forward requests from the /ssr path to the API Gateway endpoint. This calls the Lambda function where the rendering is happening.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With