Lesson 10 of 11
Practice & Quiz - Shipping to Production
Capstone quiz covering EAS Build, OTA updates, push notifications with Firebase, deep linking, app signing, and CI/CD with GitHub Actions with a practical exercise and 5 questions.
Practical Exercise - Firebase Push Notifications with Expo
// ─── Push notification setup with expo-notifications + Firebase ─
import { useEffect, useRef } from 'react';
import * as Notifications from 'expo-notifications';
import * as Device from 'expo-device';
import { Platform } from 'react-native';
import Constants from 'expo-constants';
// ─── Configure how notifications appear when app is foreground ─
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: false,
}),
});
// ─── Register device for push notifications ────────────────────
async function registerForPushNotifications(): Promise<string | null> {
if (!Device.isDevice) {
console.warn('Push notifications require a physical device');
return null;
}
const { status: existingStatus } = await Notifications.getPermissionsAsync();
let finalStatus = existingStatus;
if (existingStatus !== 'granted') {
const { status } = await Notifications.requestPermissionsAsync();
finalStatus = status;
}
if (finalStatus !== 'granted') {
console.warn('Push notification permission denied');
return null;
}
// Android: set up notification channel
if (Platform.OS === 'android') {
await Notifications.setNotificationChannelAsync('default', {
name: 'Default',
importance: Notifications.AndroidImportance.MAX,
vibrationPattern: [0, 250, 250, 250],
lightColor: '#229c6b',
});
}
// Get the Expo Push Token (FCM for Android, APNs for iOS via Expo)
const projectId = Constants.expoConfig?.extra?.eas?.projectId;
const { data: pushToken } = await Notifications.getExpoPushTokenAsync({ projectId });
// Send this token to your backend to store for this user
return pushToken;
}
// ─── Hook to set up notification listeners ────────────────────
export function usePushNotifications(
onNotification?: (notification: Notifications.Notification) => void,
onResponse?: (response: Notifications.NotificationResponse) => void,
) {
const notificationListener = useRef<Notifications.Subscription>();
const responseListener = useRef<Notifications.Subscription>();
useEffect(() => {
registerForPushNotifications().then(token => {
if (token) {
console.log('Push token:', token);
// POST token to your API: api.post('/users/push-token', { token });
}
});
// Fires when notification received while app is OPEN
notificationListener.current = Notifications.addNotificationReceivedListener(
notification => onNotification?.(notification)
);
// Fires when user TAPS a notification (foreground or background)
responseListener.current = Notifications.addNotificationResponseReceivedListener(
response => onResponse?.(response)
);
return () => {
notificationListener.current?.remove();
responseListener.current?.remove();
};
}, []);
}
// ─── Usage in App.tsx ─────────────────────────────────────────
// usePushNotifications(
// (notification) => console.log('Received:', notification.request.content.title),
// (response) => {
// const data = response.notification.request.content.data;
// if (data.screen) navigation.navigate(data.screen, data.params);
// }
// );
// ─── eas.json (EAS Build config) ─────────────────────────────
// {
// "build": {
// "development": { "developmentClient": true, "distribution": "internal" },
// "preview": { "distribution": "internal" },
// "production": {}
// }
// }Capstone Quiz
What is EAS Build and how does it differ from local `expo run:android`?
Tip
Tip
Practice Practice Quiz Shipping to Production in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Final mastery review of EAS Build, OTA Updates, SSL Pinning, and App Store publishing
Practice Task
Note
Practice Task - (1) Write a working example of Practice Quiz Shipping to Production from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Common Mistake
Warning
A common mistake with Practice Quiz Shipping to Production is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready react native code.
Finished this lesson?