Skip to main content

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.

12 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Practical Exercise - Firebase Push Notifications with Expo

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

Capstone Quiz
Question 1 of 5

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.

Diagram
Loading diagram…

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.

Topics in This Module

0/11 done

Final Projects

Congratulations on completing the course! Apply everything you've learned by building one of these real-world projects.

Project 1: Fitness Tracker App

Intermediate

Build a mobile fitness tracking app with workout logging and progress charts.

React NativeAsyncStorageVictory Charts
Key features
Workout logging Progress charts Exercise library Goal tracking
18-24 hoursGoal: A published mobile app.

Project 2: Food Delivery App UI

Intermediate

Create a Uber Eats-style food delivery app with restaurant listings and cart.

React NativeReact NavigationRedux
Key features
Restaurant map Menu browsing Cart management Order tracking
16-22 hoursGoal: A portfolio-quality mobile app.

Project 3: Chat Messenger App

Advanced

Build a real-time chat app for iOS and Android with push notifications.

React NativeFirebasePush Notifications
Key features
Real-time messaging Push notifications Media sharing Group chats
24-32 hoursGoal: A cross-platform chat application.