Complete the code to import the module that allows access to native device features in React Native.
import { [1] } from 'react-native';
The NativeModules object in React Native provides access to native device features.
Complete the code to call a native method named 'getBatteryLevel' from NativeModules.
NativeModules.[1].getBatteryLevel();The native module is usually named BatteryManager to manage battery-related features.
Fix the error in the code to correctly use a native feature to vibrate the device.
import { Vibration } from 'react-native'; Vibration.[1](1000);
The correct method to vibrate the device is vibrate.
Fill both blanks to create a native event listener for app state changes.
import { AppState } from 'react-native'; AppState.[1]('change', [2] => { console.log('App state is', [2]); });
Use addEventListener to listen for changes, and the callback parameter is commonly named nextState.
Fill all three blanks to create a native module call that returns device info asynchronously.
import { NativeModules } from 'react-native'; async function getDeviceInfo() { const info = await NativeModules.[1].[2](); console.log(info.[3]); }
The native module is DeviceInfo, the method to call is getInfo, and the device model is accessed via the model property.