Clavem

Licensing a menu bar app with Stripe and license keys

A menu bar app is launched once and then runs for weeks, so checking the license only at launch is not enough. Add a menu item that opens a small key window, re-validate about once a day on a timer, and treat the first launch at login as likely to be offline.

Why a menu bar app needs its own plan

The general Mac rules in selling a macOS app apply: sell outside the Mac App Store if you want license keys, notarize the download, keep the key in the Keychain. What is different is how a menu bar app lives. It has no Dock icon if you set LSUIElement, it has no main window, and many users start it at login and never quit it.

Three things follow from that.

There is no launch to hang the check on. Clavem’s recommended flow validates “at every launch”. For a menu bar app that may be once a month. Run the same validation on a timer. NSBackgroundActivityScheduler or a plain Timer that fires daily, plus a check when the Mac wakes, works. Each valid response gives you a new token and restarts its 14-day window, so a daily check keeps the window full.

Launch at login happens before the network is ready. When a user logs in, Wi-Fi may not have connected yet. A first validate that fails at that moment is normal, not a problem. Fall back to the stored token, mark the state as licensed if the signature and dates hold, and retry when the network path becomes available, for example with NWPathMonitor. If your launch-time call shows an error, you will annoy every user who has an old Mac or a slow VPN.

There is nowhere obvious to ask for a key. Put “Enter License Key…” and “License Status” in the menu, and keep the window small. A menu bar app without a Dock icon sometimes opens its windows behind other apps; bring the app to the front when you show the license window, or the user will think the menu item did nothing.

What the user sees in each state

State Meaning What the app does
licensed Valid response, or a good stored token inside refresh_by Nothing visible
needs-network Stored token past refresh_by and no answer A line in the menu: “Connect to the internet to check your license” and keep working for a stated grace period
invalid valid: false, for example expired or refunded A line in the menu with the reason from error, and the paid features off
unlicensed No key stored Trial or free tier, plus a visible Enter License Key item

Do not use a modal alert for needs-network. A user in a meeting, with the app running in the background, will see a dialog they cannot explain.

Re-validation in practice

Say the app validates once every 24 hours and the Mac is offline for ten days. Each token is good for 14 days from the last successful check, so the app keeps running on the stored token for 4 more days, then shows the menu line. The check never blocks the UI, because the request runs on a background task with a timeout of a few seconds. If the License API answers 429 or a 5xx, treat it as “could not check” and keep the stored token; do not clear the key.

Two responses should change state at once: 404 instance_id not found means this Mac’s activation was removed on the device page, so clear what you stored and ask for the key again; and valid: false means the license has expired or was disabled. A key that was refunded is disabled, and Clavem says so on the next validate.

Trials for small utilities

A utility with a short feature list wins buyers by being easy to try. Start the trial on first launch, store the start date in the Keychain so reinstalling does not reset it, and show the days left in the menu. When it ends, switch the paid features off and keep the menu item that opens the Stripe checkout. Keep the trial in the app and create licenses only for buyers; that way the free plan’s 50 active licenses go to paying customers.

Setting Suggested value Why
License type Perpetual, with a paid major upgrade later Simple to explain; a subscription needs a server cost to justify it
Device limit 2 or 3 A desktop, a laptop and one replacement
Trial 14 days in the app, start date in the Keychain No license is issued before payment
Re-validation Daily timer, and on wake Keeps the 14-day token window full

Doing this with Clavem

Create a product, connect Stripe, map your price. After payment, the buyer gets an email and an order page with the key and your download. The app calls activate once, then validate on its timer. The Swift guide has a LicenseManager with Keychain storage and the offline fallback; call its check() from your timer as well as at launch. The offline guide covers CryptoKit.

Guides to follow

Questions

Where does a menu bar app ask for the license key?

In a menu item such as Enter License Key that opens a small window with one field and a button. Do not show the window at launch for a licensed user, and show a short message, not a modal, when the license needs attention.

How often should a long-running app re-validate?

About once a day is plenty. Each successful validation returns a fresh token that is good for 14 days, so even a week offline leaves a wide margin.