Accessing Device APIs: Camera, Location & Push Notifications
Use Expo SDK modules to request permissions and access native device capabilities.
Expo SDK Modules
The Expo SDK provides JavaScript APIs for native device capabilities. Install individual packages and request permissions before accessing hardware.
# Install what you need:
npx expo install expo-camera expo-location expo-notificationsRequesting Permissions
Always request permission before accessing sensitive device features. Check the result before proceeding.
import * as Location from 'expo-location';
async function getLocation() {
const { status } = await Location.requestForegroundPermissionsAsync();
if (status !== 'granted') {
Alert.alert('Permission denied');
return;
}
const location = await Location.getCurrentPositionAsync({});
console.log(location.coords);
}All lessons in this course
- React Native Core Components vs Web DOM
- Styling with StyleSheet API & Flexbox
- Navigation with Expo Router
- Accessing Device APIs: Camera, Location & Push Notifications