Skip to content

๐Ÿ”” Push Notifications โ€‹

Push notifications alert customers when their order status changes (e.g., "Your order is being prepared", "Your order is ready for pickup"). KitchenAsty uses Expo Push Notifications, which handles both iOS (APNs) and Android (FCM) through a unified API.

๐Ÿ”„ How It Works โ€‹

KitchenAsty Server โ†’ Expo Push Service โ†’ APNs (iOS) / FCM (Android) โ†’ Customer's Phone
  1. ๐Ÿ“ฑ When a customer opens the app, it registers for push notifications and sends the Expo Push Token to your server
  2. ๐Ÿ“ค When an order status changes, your server sends a push notification via the Expo Push API
  3. ๐Ÿ”€ Expo routes the notification to Apple (APNs) or Google (FCM)
  4. ๐Ÿ”” The customer sees the notification on their phone

๐Ÿค– Android Setup (FCM) โ€‹

Android push notifications work through Firebase Cloud Messaging (FCM).

1๏ธโƒฃ Step 1: Create a Firebase Project โ€‹

  1. Go to console.firebase.google.com
  2. Click "Create a project" (or use an existing one)
  3. Enter your project name (e.g., "KitchenAsty")
  4. Disable Google Analytics (optional, not needed for push)
  5. Click "Create project"

2๏ธโƒฃ Step 2: Add an Android App to Firebase โ€‹

  1. In the Firebase Console, click the Android icon to add an app
  2. Enter your Android package name: Must match android.package in app.json (e.g., com.mariospizza.app)
  3. Enter an App nickname: Your restaurant name
  4. ๐Ÿ”‘ SHA-1 certificate fingerprint: Get it from EAS:
    bash
    eas credentials --platform android
    # Look for the SHA-1 fingerprint
  5. Click "Register app"
  6. ๐Ÿ“ฅ Download the google-services.json file
  7. Place it at packages/mobile/google-services.json

3๏ธโƒฃ Step 3: Get the FCM Server Key โ€‹

  1. In Firebase Console, go to Project Settings โ†’ Cloud Messaging tab
  2. If "Cloud Messaging API (V1)" is enabled, you're set (Expo uses FCM v1)
  3. If you see "Cloud Messaging API (Legacy)" is disabled, click the three dots and enable it

4๏ธโƒฃ Step 4: Upload FCM Credentials to Expo โ€‹

bash
eas credentials --platform android

Select "Push Notifications: Manage your FCM API key" and follow the prompts to upload your Firebase service account key.

Alternatively, upload via the Expo website:

  1. ๐ŸŒ Go to expo.dev โ†’ Your project โ†’ Credentials
  2. ๐Ÿค– Select Android โ†’ Push Notifications
  3. ๐Ÿ“ค Upload the FCM server key or service account JSON

5๏ธโƒฃ Step 5: Add to app.json โ€‹

Add the Firebase config to your app.json:

json
{
  "expo": {
    "android": {
      "googleServicesFile": "./google-services.json"
    }
  }
}

๐ŸŽ iOS Setup (APNs) โ€‹

iOS push notifications work through Apple Push Notification service (APNs).

1๏ธโƒฃ Step 1: Enable Push Notification Capability โ€‹

If you haven't already when creating the App ID:

  1. Go to developer.apple.com/account/resources/identifiers
  2. Click your app's identifier
  3. Check "Push Notifications"
  4. Click "Save"

2๏ธโƒฃ Step 2: Create an APNs Key โ€‹

  1. Go to developer.apple.com/account/resources/authkeys
  2. Click the "+" button to create a new key
  3. Enter a name: "KitchenAsty Push Key"
  4. Check "Apple Push Notifications service (APNs)"
  5. Click "Continue" then "Register"
  6. ๐Ÿ“ฅ Download the .p8 key file โ€” you can only download it once!
  7. ๐Ÿ“ Note the Key ID shown on the page
  8. ๐Ÿ“ Note your Team ID (shown at the top right of the developer portal, or in Membership โ†’ Team ID)

๐Ÿšจ Save Your APNs Key

The .p8 key file can only be downloaded once. Store it securely (password manager, encrypted backup). If you lose it, you'll need to create a new key.

3๏ธโƒฃ Step 3: Upload APNs Key to Expo โ€‹

bash
eas credentials --platform ios

Select "Push Notifications: Manage your Apple Push Notifications Key" and provide:

  • ๐Ÿ”‘ The .p8 key file
  • ๐Ÿท๏ธ The Key ID
  • ๐Ÿ‘ฅ Your Apple Team ID

Alternatively, upload via the Expo website:

  1. ๐ŸŒ Go to expo.dev โ†’ Your project โ†’ Credentials
  2. ๐ŸŽ Select iOS โ†’ Push Notifications
  3. ๐Ÿ“ค Upload the .p8 file, Key ID, and Team ID

๐Ÿ–ฅ๏ธ Server Configuration โ€‹

The KitchenAsty server already includes push notification support via expo-server-sdk. The server automatically:

  1. ๐Ÿ’พ Stores the customer's Expo Push Token when they log in (via POST /api/auth/push-token)
  2. ๐Ÿ“ค Sends push notifications when order status changes (in packages/server/src/lib/socket.ts)

No additional server configuration is needed.

๐Ÿงช Testing Push Notifications โ€‹

๐Ÿ”ง Using Expo's Push Tool โ€‹

  1. ๐Ÿ“ฑ Open the app on a real device (push notifications don't work in simulators)
  2. ๐Ÿ”‘ Log in โ€” the app registers for push and sends the token to your server
  3. ๐ŸŒ Go to expo.dev/notifications
  4. ๐Ÿ“ Enter the Expo Push Token (find it in your server logs or database)
  5. โœ๏ธ Enter a title and body
  6. ๐Ÿ“ค Click "Send a Notification"

๐Ÿ“ฆ Testing via Order Status Change โ€‹

  1. ๐Ÿ›’ Place an order through the app
  2. ๐Ÿ”„ In the Admin Dashboard, change the order status (e.g., from "Pending" to "Preparing")
  3. ๐Ÿ”” The customer should receive a push notification on their phone

๐Ÿ“‹ Notification Content โ€‹

KitchenAsty sends these notifications:

Order StatusNotification TitleBody
โœ… CONFIRMEDOrder ConfirmedYour order #KA-XXX has been confirmed
๐Ÿณ PREPARINGBeing PreparedYour order #KA-XXX is being prepared
โœ… READYReady!Your order #KA-XXX is ready for pickup
๐Ÿšš OUT_FOR_DELIVERYOn Its WayYour order #KA-XXX is out for delivery
๐Ÿ“ฆ DELIVEREDDeliveredYour order #KA-XXX has been delivered. Enjoy!

๐Ÿ”ง Troubleshooting โ€‹

โŒ Notifications Not Arriving โ€‹

  1. ๐Ÿ” Check permissions: Make sure the user granted notification permissions on their device
  2. ๐Ÿ”‘ Check the token: Verify the Expo Push Token is saved in the database (Customer.expoPushToken field)
  3. ๐Ÿงช Test with Expo's tool: Use expo.dev/notifications to send a test notification directly
  4. ๐Ÿ“‹ Check server logs: Look for push notification errors in docker compose logs server
  5. ๐Ÿ“ฑ Physical device required: Push notifications do not work in iOS Simulator or Android Emulator

๐ŸŽ iOS Notifications Not Working in Production โ€‹

  • โœ… Ensure the APNs key is uploaded to Expo
  • โœ… Ensure Push Notifications capability is enabled on the App ID
  • โœ… Ensure the provisioning profile includes push notification entitlement
  • ๐Ÿ”จ Rebuild the app after making credential changes

๐Ÿค– Android Notifications Not Working โ€‹

  • โœ… Ensure google-services.json is in the correct location
  • โœ… Ensure the FCM key is uploaded to Expo
  • ๐Ÿ”จ Ensure the app was rebuilt after adding google-services.json

โžก๏ธ Next Step โ€‹

Continue to Updates & Maintenance to learn how to publish app updates.