๐ 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- ๐ฑ When a customer opens the app, it registers for push notifications and sends the Expo Push Token to your server
- ๐ค When an order status changes, your server sends a push notification via the Expo Push API
- ๐ Expo routes the notification to Apple (APNs) or Google (FCM)
- ๐ 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 โ
- Go to console.firebase.google.com
- Click "Create a project" (or use an existing one)
- Enter your project name (e.g., "KitchenAsty")
- Disable Google Analytics (optional, not needed for push)
- Click "Create project"
2๏ธโฃ Step 2: Add an Android App to Firebase โ
- In the Firebase Console, click the Android icon to add an app
- Enter your Android package name: Must match
android.packageinapp.json(e.g.,com.mariospizza.app) - Enter an App nickname: Your restaurant name
- ๐ SHA-1 certificate fingerprint: Get it from EAS:bash
eas credentials --platform android # Look for the SHA-1 fingerprint - Click "Register app"
- ๐ฅ Download the
google-services.jsonfile - Place it at
packages/mobile/google-services.json
3๏ธโฃ Step 3: Get the FCM Server Key โ
- In Firebase Console, go to Project Settings โ Cloud Messaging tab
- If "Cloud Messaging API (V1)" is enabled, you're set (Expo uses FCM v1)
- If you see "Cloud Messaging API (Legacy)" is disabled, click the three dots and enable it
4๏ธโฃ Step 4: Upload FCM Credentials to Expo โ
eas credentials --platform androidSelect "Push Notifications: Manage your FCM API key" and follow the prompts to upload your Firebase service account key.
Alternatively, upload via the Expo website:
- ๐ Go to expo.dev โ Your project โ Credentials
- ๐ค Select Android โ Push Notifications
- ๐ค Upload the FCM server key or service account JSON
5๏ธโฃ Step 5: Add to app.json โ
Add the Firebase config to your app.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:
- Go to developer.apple.com/account/resources/identifiers
- Click your app's identifier
- Check "Push Notifications"
- Click "Save"
2๏ธโฃ Step 2: Create an APNs Key โ
- Go to developer.apple.com/account/resources/authkeys
- Click the "+" button to create a new key
- Enter a name: "KitchenAsty Push Key"
- Check "Apple Push Notifications service (APNs)"
- Click "Continue" then "Register"
- ๐ฅ Download the
.p8key file โ you can only download it once! - ๐ Note the Key ID shown on the page
- ๐ 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 โ
eas credentials --platform iosSelect "Push Notifications: Manage your Apple Push Notifications Key" and provide:
- ๐ The
.p8key file - ๐ท๏ธ The Key ID
- ๐ฅ Your Apple Team ID
Alternatively, upload via the Expo website:
- ๐ Go to expo.dev โ Your project โ Credentials
- ๐ Select iOS โ Push Notifications
- ๐ค Upload the
.p8file, Key ID, and Team ID
๐ฅ๏ธ Server Configuration โ
The KitchenAsty server already includes push notification support via expo-server-sdk. The server automatically:
- ๐พ Stores the customer's Expo Push Token when they log in (via
POST /api/auth/push-token) - ๐ค 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 โ
- ๐ฑ Open the app on a real device (push notifications don't work in simulators)
- ๐ Log in โ the app registers for push and sends the token to your server
- ๐ Go to expo.dev/notifications
- ๐ Enter the Expo Push Token (find it in your server logs or database)
- โ๏ธ Enter a title and body
- ๐ค Click "Send a Notification"
๐ฆ Testing via Order Status Change โ
- ๐ Place an order through the app
- ๐ In the Admin Dashboard, change the order status (e.g., from "Pending" to "Preparing")
- ๐ The customer should receive a push notification on their phone
๐ Notification Content โ
KitchenAsty sends these notifications:
| Order Status | Notification Title | Body |
|---|---|---|
| โ CONFIRMED | Order Confirmed | Your order #KA-XXX has been confirmed |
| ๐ณ PREPARING | Being Prepared | Your order #KA-XXX is being prepared |
| โ READY | Ready! | Your order #KA-XXX is ready for pickup |
| ๐ OUT_FOR_DELIVERY | On Its Way | Your order #KA-XXX is out for delivery |
| ๐ฆ DELIVERED | Delivered | Your order #KA-XXX has been delivered. Enjoy! |
๐ง Troubleshooting โ
โ Notifications Not Arriving โ
- ๐ Check permissions: Make sure the user granted notification permissions on their device
- ๐ Check the token: Verify the Expo Push Token is saved in the database (
Customer.expoPushTokenfield) - ๐งช Test with Expo's tool: Use expo.dev/notifications to send a test notification directly
- ๐ Check server logs: Look for push notification errors in
docker compose logs server - ๐ฑ 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.jsonis 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.