The API contains two implementations:
- RecommendationManager
- RecommendationManager2
Get started
Permissions
The API requires authentication through the use of privileges. Specifically, an app requirescom.amazon.privilege.security.file-sharing privilege to access the API for adding recommendations.
Setup
- Add the following library dependency to the
dependenciessection of your package.json file.
- Add the following privileges in your manifest.toml.
Usage
Adding Recommendations
- Create a
Recommendation2object with the required fields (title, text, content image, category, display name, display action option, etc.). - Call the
addRecommendations2method of theRecommendationManager2class, passing an array ofRecommendation2objects. - The method returns an array of numbers representing the newly added recommendations. Each number corresponds to a recommendation and is used to remove the recommendations in the future:
- If you specify the content image byte array, the image is stored on the device immediately
- If you speicfy the content image URI, the image is downloaded asynchronously. If the image download fails, the recommendation is removed and an error message is logged that indicates that the content image URI download failed.
/ to URLs. This can cause content image URIs to fail downloading. To work around this issue:
- Create the URL using the standard URL constructor
- Manually set the
_urlfield to the exact URL string desired
react-native-url-polyfill) are not compatible as Recommendation Manager requires specific fields from the standard URL object.
Example:
Removing Recommendations
- To remove specific recommendations, call the
removeRecommendations()method of theRecommendationManager2class, passing an array of numbers representing the recommendations to remove. - To remove all recommendations sent by the client app, call the
removeAllRecommendations()method of theRecommendationManager2class.
Legacy Use Cases (Version 1.x.x)
Adding legcacy recommendations
- Create a
Recommendationobject with the required fields (title, text, content image, category, display name, display action option, etc.). - Call the
addRecommendations()method of theRecommendationManagerclass, passing an array ofRecommendationobjects. - The method returns an array of numbers representing the newly added recommendations. Each number corresponds to a recommendation and which that the can use to remove the recommendations in the future.
Removing legacy recommendations
- To remove specific recommendations, call the
removeRecommendations()method of theRecommendationManagerclass, passing an array of numbers representing the recommendations to remove. - To remove all recommendations sent by the client app, call the
removeAllRecommendations()method of theRecommendationManagerclass.
The description of recommendation field is as follows
Acceptable image specification
- Aspect ratio: 16:9
- Channels: 3 (BGR) with 8 bit/channel
- Orientation: Landscape
- Format: PNG
- Depending on the display, the image resolution should be:
- HDTV (720p): 256 * 144
- HDTV (1080p): 384 * 216
- 4K UHD: 768 * 432
- Title: Embedded within image
- Transparency: No transparency
Supported maturity rating values
- US Marketplace: G, PG, PG13, R, NC17, NR, TVY, TVY7, TVG, TVPG, TV14, TVMA
- German Marketplace: FSK0, FSK6, FSK12, FSK16, FSK18
- Great Britain Marketplace: BBFCPG, BBFC12, BBFC18, BBFCU
- Japan Marketplace: EIRIN_G, EIRIN_PG12, EIRIN_R15, EIRIN_18
- India Marketplace: ALL, 7+, 13+, 16+, 18+, NR
Troubleshooting
-
SecurityError: This error occurs when the calling app does not have the required
com.amazon.privilege.security.file-sharingprivilege. Make sure that your app has the necessary privileges before you make calls to the API. -
InvalidArgumentError: This error can occur in the following scenarios:
- The size of a recommendation object exceeds 512KB (excluding the content image size).
- Mandatory fields in the
Recommendationobject are empty or invalid. - The content image does not meet the specified dimensions and size requirements.
- The size of the recommendations array passed to
addRecommendations()is greater than 20.
-
In cases where recommendations aren’t showing up:
- If you used that content image URI, check whether the images failed to download . If the image download failed, the recommendation isn’t added. Device logs will show that the image download failed. For example:
- Check if the recommendation was successfully added to the Recommendation Manager database using the unique row ID. You can find the unique row ID can be found in the logs:
unique-row-id, check the config file corresponding to the unique row ID. The file contains the recommendations that have been successfully added to the row. If the file is empty, that means the calling app’s recommendations weren’t added. Check device logs for error logs when calling addRecommendations.
Modules
- index
- RecommendationManager
- RecommendationManager2
- turbo-modules/RecommendationManagerTurboModule
- turbo-modules/RecommendationManagerTurboModule
- types/RecommendationManagerTypes
- types/RecommendationManagerTypes

