# iOS app

> The Postern app for iPhone and iPad, building it with Xcode until it is in the App Store, connecting, notifications, App Lock, swipe actions and what iOS pauses in the background.

Source: https://docs.posternmail.app/apps/ios/

Postern for iPhone and iPad is built for quick triage with one hand: swipe actions, quick
replies, its own copy of your mail and an optional App Lock. This page covers getting the app,
connecting it, notifications and how it behaves in the background.

Like the desktop app, the iOS app runs the mail engine inside the app ("direct mode", see
[Apps](https://docs.posternmail.app/apps/#direct-mode-and-through-your-hub)): it connects straight to your providers
and keeps working when your Hub is down.

## Status

The iOS app is being prepared for the App Store. Until it is there, build it from source with
Xcode and install it on your own device. The in-app mail engine has been verified on the iOS
simulator.

## Build the app

### What you need

- A Mac with **Xcode** (from the App Store) and its command line tools.
- **Git**, **Node.js 24** or newer with **pnpm 11** (`corepack enable`), and **Go 1.27** or
  newer.
- **gomobile**, which builds the mail engine as an iOS framework.
- For your own iPhone or iPad: an **Apple account** signed in to Xcode. A free account can
  install the app on your own devices for testing; Apple limits such installs to 7 days, after
  which you build and install again. Push notifications need a paid **Apple Developer Program**
  membership.

### Build and run

```sh
git clone https://github.com/TheOriUHD/postern.git
cd postern
corepack enable
pnpm install
go install golang.org/x/mobile/cmd/gomobile@latest golang.org/x/mobile/cmd/gobind@latest
export PATH="$(go env GOPATH)/bin:$PATH"
gomobile init
apps/mobile/scripts/build-engine.sh
pnpm --filter @postern/mobile ios
```

| Command | What it does |
|---|---|
| `apps/mobile/scripts/build-engine.sh` | Builds the mail engine with gomobile into `apps/mobile/modules/mail-engine/ios/Engine.xcframework` (device and simulator). `IOS_MIN` sets the minimum iOS version of the framework (default `15.1`). |
| `pnpm --filter @postern/mobile ios` | Runs `expo run:ios`: generates the Xcode project in `apps/mobile/ios/`, installs the native dependencies, builds the app and starts it in the iOS simulator. |

> [!IMPORTANT]
> Without `build-engine.sh` the app still builds, but without the mail engine. It then loads
> all mail through your Hub, and **Settings → About** says "This version of the app loads mail
> through your Hub."

> **Check:** the simulator opens Postern with **Scan QR code**, **Enter Hub address** and **Try
> the demo**.

> **If it did not work:** `build-engine.sh` stops with "gomobile not found" when `gomobile` is
> not on your `PATH`: run the `export PATH` line again. Rebuild the native app
> (`pnpm --filter @postern/mobile ios`) after every `build-engine.sh` run.

### Install it on your iPhone or iPad

1. Connect the device with a cable and turn on **Developer Mode** on it (**Settings → Privacy
   & Security → Developer Mode**) if iOS asks for it.
2. Open `apps/mobile/ios/Postern.xcworkspace` in Xcode. Under **Signing & Capabilities**,
   choose your team for both targets, **Postern** and **PosternNotificationService**.
3. If Xcode says the bundle identifier `app.postern` is not available to your team, set your
   own in `apps/mobile/app.json` (`expo.ios.bundleIdentifier`, for example
   `com.example.postern`) and regenerate the project:

   ```sh
   cd apps/mobile
   npx expo prebuild --platform ios --clean
   ```

4. Build a release build onto the device:

   ```sh
   cd apps/mobile
   npx expo run:ios --device --configuration Release
   ```

   Pick your device from the list.

> **Check:** Postern starts on the device.

> **If it did not work:** on the device, open **Settings → General → VPN & Device
> Management** and trust your developer certificate, then start the app again.

> [!NOTE]
> A debug build (without `--configuration Release`) loads its code from the development server
> on your Mac (`pnpm --filter @postern/mobile start`) and does not work away from it.

### Push notifications for your own build

Apple delivers push notifications only to apps signed by the team whose key sent them. A build
you signed yourself therefore needs a [push relay](https://docs.posternmail.app/relay/) that has an APNs key from your
own Apple Developer account and your bundle identifier as its topic (`APNS_TOPIC`). Builds run
from Xcode get development push tokens, so that relay also needs `APNS_SANDBOX=true`. See
[Run your own relay](https://docs.posternmail.app/relay/run-your-own/).

Without a working relay the app still works; you only get no notifications while it is closed.

## Connect to your Hub

The first screen offers three ways in.

| Button | What happens |
|---|---|
| **Scan QR code** | Scan the code from **Settings → Devices → Connect a device** on a device that is already signed in, or in the web app. Fastest. See [Pairing a device](https://docs.posternmail.app/apps/pairing/). |
| **Enter Hub address** | Type the address, for example `mail.example.com` or `192.168.1.20:8080`, tap **Continue**, then **Sign in with browser**. |
| **Try the demo** | Sample mailboxes on the phone. Nothing is sent. |

With **Enter Hub address**:

1. The app checks the address. It shows the Hub's name and version, and "Not encrypted (HTTP)"
   for a plain HTTP address.
2. **Sign in with browser** opens your Hub's sign-in page in a secure browser sheet. Sign in
   with a passkey, your password (and two-step code), or single sign-on.
3. Tap **Allow and open the app**. The sheet closes and the app says "Setting up your
   mailboxes… The first time can take up to half a minute."

The app never sees your password: it receives a session through a one-time code protected with
PKCE. If the Hub hasn't been set up yet, the app says so and offers **Open setup in browser**.

A Hub behind Cloudflare Access works: the browser sheet first asks for your email address
(Cloudflare's code), then shows your Hub's page. Scanning the QR code from the web app skips
the email step.

### Unencrypted (HTTP) Hubs

The app connects over plain HTTP without asking only when the Hub is on the device or the local
network: `localhost`, private addresses (10.x, 172.16 to 31.x, 192.168.x, 100.64 to 127.x),
names ending in `.local`, `.lan`, `.home.arpa` or `.internal`, and single-word names. Any other
HTTP address shows **This Hub isn't encrypted** and needs **Connect without encryption**.

iOS itself allows plain HTTP only to local network addresses (IP addresses, single-word names
and `.local` names). A Hub reached over HTTP by any other name needs HTTPS. See
[HTTPS](https://docs.posternmail.app/reach/https/).

## Where your mail comes from

**Settings → About** shows under **Your mail**:

| Row | Values |
|---|---|
| Mail is loaded | **On this iPhone** (direct mode) or **Through your Hub** |
| Your Hub | **Connected**, **Sending 3 changes…**, or **Can't be reached** (with the number of changes waiting) |
| Last in step with your Hub | When the phone last synced with the Hub |

If the engine couldn't start, the app uses your Hub's copy, shows "Showing mail from your Hub"
and offers **Try loading mail on this iPhone again**. It also tries again by itself whenever
you open it. The **Details** section below lists the app version, the Hub version and the
connection state, which helps when you ask someone for help.

## Notifications

Turn them on in **Settings → Notifications → This device → Notifications** and allow them when
iOS asks.

| Message | Meaning |
|---|---|
| Your Hub isn't set up to send notifications yet. Whoever runs it can turn that on in the Hub's settings. | The Hub has no push relay (`POSTERN_RELAY_URL` is empty). |
| Notifications are turned off for Postern in the Settings app. | You denied permission. **Open Settings** goes there. |
| Notifications will be turned on as soon as your Hub can be reached. | The Hub is down; the app registers later. |

- New mail shows as a message from its sender, with the sender's picture, the subject and the
  first words.
- **Show previews on phones** (in the same screen, synced for all devices) controls whether
  the sender and subject travel through the relay and Apple. Turned off, the notification
  only says "New mail". See [What the relay sees](https://docs.posternmail.app/relay/what-it-sees/).
- **Archive** and **Mark as Read** buttons appear when you press and hold a notification. They
  run in the background, without opening the app.
- When you read or archive mail elsewhere, its notifications are removed the next time the app
  syncs. Once nothing in the Inbox is unread, all mail notifications go.
- **Notify me about** (**All new mail**, **VIPs only**, **Nothing**) and **Quiet hours** apply
  to all your devices. See [Notifications](https://docs.posternmail.app/using/notifications/).

## App Lock

**Settings → This iPhone → App Lock** asks for Face ID, Touch ID or your passcode when you open
Postern. It is a per-device setting and off by default.

- The lock covers the app before any mail is shown, and covers it in the app switcher.
- It locks again after the app has been in the background for more than a minute.
- After a cancelled prompt, tap **Unlock**. Too many failed tries say "Too many tries. Unlock
  with your passcode."
- If you remove the device passcode, App Lock turns itself off and says so.
- A request to connect a new device waits until you unlock the app.

## Swipe actions

Swipe a conversation in a list to act on it. A full swipe does the action. Choose the actions
in **Settings → Swipe actions**, for **Swipe right** and **Swipe left**:

| Choice | Default |
|---|---|
| Archive | Swipe left |
| Trash | |
| Mark as read or unread | Swipe right |
| Star | |
| Snooze | |
| Nothing | |

The choices apply to Postern on all your devices.

## Offline and in the background

In direct mode the app reads, searches, sends and organizes mail without your Hub, and syncs
the changes when it is back. See [Working offline](https://docs.posternmail.app/apps/offline/).

iOS pauses apps soon after you leave them. While Postern is paused:

- It doesn't fetch mail and keeps no connection to your providers or your Hub.
- New-mail notifications come from your Hub through the push relay. Your Hub watches your
  inboxes all the time, so these arrive within seconds.
- Scheduled sends, snoozes, follow-ups and rules are run by your Hub, not by the phone.
- Mail written while offline waits in the phone's outbox until you open the app again.

When you open the app, it catches up at once. The app does not use iOS background refresh, so
without a push relay nothing new shows until you open it.

## Apple Watch

Postern on Apple Watch shows your Inbox on your wrist. On the watch you can read a
conversation, reply by dictation or a quick reply, and archive, trash, star or snooze. It is
installed with the iPhone app and needs the phone to be signed in to your Hub (not the demo).

To connect it, tap **Connect** on the watch and confirm on the iPhone. You can also go to
**Settings → Apple Watch → Connect Apple Watch** on the phone. The watch gets its own sign-in
to your Hub, listed as "Apple Watch" next to your phone in **Settings → Devices**.

That sign-in is limited:
- It never receives your mailbox passwords.
- When you sign the phone out, the watch is signed out too.
- With Hubs before companion devices (no `companionDevices` capability), the phone pairs the
  watch instead. It then shows as an "iPhone or iPad" device named "Apple Watch", and you sign
  it out on its own.

When the watch can't reach your Hub, it goes through your iPhone.

## Lost your phone

Sign it out from **Settings → Devices** on another device. See
[Lost or stolen device](https://docs.posternmail.app/apps/pairing/#lost-or-stolen-device).
