Efficiently Achieving Device-Based Theme Change with AWS Lambda

Device-Based Theme Change with AWS Lambda

Prev Question Next Question

Question

You are deploying a mobile application for an eCommerce company.

They require you to change themes based on the device type.

Android devices see a green theme and iOS devices see blue.

You are advised to use AWS Lambda for your mobile backend deployment.

How could this be achieved efficiently?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer: C.

Option A is incorrect as this is not very efficient as it requires writing code at the application level to send data to the Lambda function to process.

Option B is incorrect as environment variables are used for more constant information and can be used during runtime.

Option C is CORRECT as per AWS Lambda FAQ's the context object, when called through AWS Mobile SDK, will give the Lambda function automatic access to device and application information to them use to change themes.

Option D is incorrect as the event object will not have the device information required.

Reference:

https://aws.amazon.com/lambda/faqs/

The most efficient way to achieve the theme change based on device type for a mobile application deployed on AWS Lambda backend is to use option C: Use AWS Mobile SDK and use the “context” object.

Option A: Use a REST client to pass device info to API Gateway that invokes AWS Lambda function is not the most efficient way because passing device information through the API Gateway will require additional network requests and could add latency to the application.

Option B: Different environment variables for Android and iOS may work, but it would require updating the environment variables for every new device type, which is not scalable.

Option C: Use AWS Mobile SDK and use the “context” object is the most efficient way to achieve the theme change based on device type. The AWS Mobile SDK provides a “context” object that can be used to determine the platform of the device calling the Lambda function. This information can be used to return the appropriate theme to the device.

Option D: Use the “event” object to determine which device invoked the function is not the best option because the “event” object does not contain information about the device calling the function. The “event” object contains information about the event that triggered the Lambda function.