The Vega SDK has support for headless tasks and services, which give you the ability to run JavaScript code in the background, separate from your app’s UI. Some feature integrations use them (Live TV, Content Personalization, Account Login)**. Headless tasks and services have their own React Native runtime, which has the constraints listed below.
-
UI Components and APIs aren’t Allowed: You cannot import UI components or APIs (e.g. DeviceInfo, AppState, etc.) in a headless task or service. If you do (e.g.
import{ ImageBackground, Text, View, ViewStyle }from'react-native'), the process will crash. -
Only Specific Modules are Allowed: Supported modules are listed here. If you import a module that isn’t supported, the process will crash.
-
Deep Import Module Dependencies: Make sure you’re not importing components from ‘react-native’. For example:
// This will include all of the exported components of RN which includes UI components.
// Don't do this!
import Platform from 'react-native';
// Instead, deep import each dependency like this:
import Platform from '@amzn/react-native-kepler/Libraries/Utilities/Platform';
// or this:
const Platform = require('@amzn/react-native-kepler/Libraries/Utilities/Platform');
If you see errors like, “Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DeviceInfo' could not be found” (you may have a different component name than ‘DeviceInfo’) in the logs, then you probably have a problematic import, or one of your dependencies has a problematic import. Please review the troubleshooting steps to root cause and resolve the issue.
** Important: At this time, these feature integrations are available to select partners only.