Setting Up iOS Push Notifications with Expo
Push notifications let your app reach people even when it’s closed. There’s more than one way to send them, but this guide covers Expo’s push service, the most common path. On iOS, Expo delivers through Apple Push Notification service (APNs). Most of this guide is code the AI Agent writes for you; the last two steps happen once in a terminal, because they involve an interactive credential setup that can’t be run through the Builder or the AI Agent.
Before you begin, make sure you have:
- Your app in Draftbit with the screen(s) you want notifications on
- An active Apple Developer Program membership
- A Bundle ID created for your app (see iOS Publishing (Cloud))
- A free Expo account—step 2 covers creating one
- A few minutes at a terminal with your project exported (steps 6–7)
1. Design the UI, then ask the AI Agent to wire it up
Section titled “1. Design the UI, then ask the AI Agent to wire it up”Add the permission prompt, a notifications toggle in settings, or wherever the in-app banner should land. Once the screens exist, ask the AI Agent in AI Chat to connect them using expo-notifications, the library that talks to iOS’s notification system on your behalf:
“Add push notification support using expo-notifications. Request permission the first time the user opens the app, register for an Expo push token once permission is granted, and store that token against the signed-in user. Add a listener that shows an in-app banner when a notification arrives while the app is open, and navigates to the relevant screen when the user taps a notification.”
2. Create an Expo account
Section titled “2. Create an Expo account”Expo is the service that actually delivers the push—your app sends notifications through it rather than talking to Apple directly. Skip this if you already have an account, including if you’ve already set this up for Android.
- Go to expo.dev/signup and sign up with an email or GitHub.
- Verify your email from the link Expo sends you.
- Note your username—you’ll need it exactly as it appears on your Expo profile in step 4.
3. Enable the Push Notifications capability
Section titled “3. Enable the Push Notifications capability”This step must be done manually in the Apple Developer portal—there’s no automatic/terminal-based alternative for this part.
- Log in to your Apple Developer account and select Identifiers from Certificates, IDs & Profiles.
- Find and select the Bundle ID you created for your app.
- Scroll to the Capabilities list and check the box next to Push Notifications.
- Click Save.
4. Generate an APNs Auth Key
Section titled “4. Generate an APNs Auth Key”You have two options here—you don’t need to do both.
Option A: Let the build process generate it automatically (recommended)
Section titled “Option A: Let the build process generate it automatically (recommended)”When you run your local build (see Run a first EAS build for iOS below), the build tool will prompt you to set up push notifications and can generate the APNs key for you automatically, as long as you sign in with your Apple Developer account when prompted. This is the simpler path for most people.
Option B: Generate it manually yourself first
Section titled “Option B: Generate it manually yourself first”If you’d rather generate the key yourself ahead of time:
-
Log in to your Apple Developer account, select Certificates, IDs & Profiles, then Keys.
-
Click the Add button (+).
-
Enter a name for the key (e.g. “Draftbit Push Notifications”).
-
Check the box for Apple Push Notifications service (APNs).
-
Click Continue, then Register.
-
On the confirmation page, click Download to save your
.p8key file. -
Note down the Key ID shown on this page, and your Team ID (found under Membership Details). You’ll provide these along with the
.p8file during the local build if you choose not to let it generate automatically.
5. Point the project at your Expo account
Section titled “5. Point the project at your Expo account”The build needs to know which Expo account owns it. Open app.config.js in your exported project and add (or update) the owner field with your Expo username from step 2:
module.exports = { owner: "your-expo-username", // ...your existing config};If you’re using the AI Agent to make changes locally, you can also just ask it:
“Set the owner field in app.config to my Expo username: your-expo-username.”
6. Run a first EAS build for iOS
Section titled “6. Run a first EAS build for iOS”Expo can’t manage push credentials for a project until it has at least one iOS build configured. The Builder can’t trigger this part: export your code and run it once from a real terminal.
- Export your project from Draftbit.
- Open a terminal in the exported folder and install dependencies:
yarn - Install the EAS CLI if you don’t already have it:
npm i -g eas-cli - Log in to Expo:
eas login - Create and link the EAS project to your account:
eas init - Generate the build config:
eas build:configure -p ios—this writeseas.json. - Kick off the build:
eas build -p ios --profile development
yarnnpm i -g eas-clieas logineas initeas build:configure -p ios# ✔ Generated eas.jsoneas build -p ios --profile developmentThis prompts you to set up your Push Notifications key—either automatically (Option A above) or using the .p8 file, Key ID, and Team ID you noted down earlier (Option B above).
7. Add your Expo Project ID to Draftbit
Section titled “7. Add your Expo Project ID to Draftbit”Your app’s Expo Project ID is shared across both platforms—it’s one Project ID per app, not a separate one for iOS vs. Android.
- If you’ve already set up push notifications for Android first, this build will simply find and reuse that same existing Project ID—you’ll see a message like
Existing EAS project found for @your-username/your-app-slug (id = ...). Use that same ID; there’s no need to generate a new one. - If iOS is the first platform you’re setting this up for, this is the step where the Project ID gets created for the first time—you’d then reuse that same ID later when setting up Android.
Copy the ID from the terminal output, then add it to app.config.js in your Draftbit project too, the same way you did locally in step 6: open Code Editing mode in the builder, edit app.config.js directly to add the extra.eas.projectId field, and save.
If you’re using the AI Agent to make changes in the builder, you can also just ask it:
“Add extra.eas.projectId with value [your ID] to app.config.js.”
This updates the builder’s own copy of app.config.js, so future builds and publishes done through Draftbit’s normal cloud pipeline have the Project ID too.
8. Publish again
Section titled “8. Publish again”The credential now lives with Expo, not in your exported copy—go back to Draftbit and publish once more so the live build picks it up. From here, a push sent through Expo’s push service reaches real iOS devices.
Retrieve a device’s push token
Section titled “Retrieve a device’s push token”The AI Agent prompt in step 1 already registers each device’s Expo push token—via expo-notifications’s getExpoPushTokenAsync()—and stores it on the signed-in user’s record. To send a notification to a specific device later, look up that stored token; there’s no separate step needed to fetch it again.
Troubleshooting
Section titled “Troubleshooting””Missing config” error when running eas credentials
Section titled “”Missing config” error when running eas credentials”You need at least one iOS build configured before credentials can be managed. Run eas build:configure -p ios (step 6) first.
Notifications aren’t arriving on a device
Section titled “Notifications aren’t arriving on a device”- Confirm the Push Notifications capability shows as enabled on your Bundle ID in the Apple Developer portal.
- Make sure the device has notification permissions granted and a push token was actually registered—ask the AI Agent to log the token after registration.
- Rebuild and republish after any credential or
app.configchange; existing installs won’t pick up new credentials until the next build.