Repository navigation
feat(cli): appwrite init apns - #2015
Conversation
The appwrite (native Go), expo (apple-utils) and fastlane (spaceship) setups behind one apns.Adapter: each signs in to the Apple Developer portal, creates an APNs key, and checks or registers the App ID with Push Notifications.
Sets up the APNs providers (sandbox and production) for an iOS app from an existing .p8 or one created by signing in with the Apple ID, detects the bundle ID and team from an Xcode project or Expo config, adds aps-environment and the remote-notification background mode, and checks the App ID on every run.
🟢 Tier S · Ready to mergeAdds Latest changes: The newest commits add persistent mock Apple sign-in and Developer portal endpoints, inject mock hosts only into the CLI E2E build, and exercise saved sign-in, App ID registration and Push activation, and the key limit.
📂 Walkthrough · 6
Reviewed the commits since |
…h needs Without an Apple platform for the bundle ID the API refuses the app's requests as an unknown origin, device registration included, and init apns left that to the console. It now adds the platform when the project has none for the bundle ID, and tells how to add it when it can't. It also ends with what init apns doesn't set up: the Appwrite push provider when the project has none enabled, and the Notification Service Extension with its App Group for background and swiped-away delivery.
The findings that requested changes are resolved. See the summary comment for what is still open.
The mock API keeps messaging providers and project platforms per project, so the harness can run the built binary on a project folder: the first run creates both APNs providers and the Apple platform and prints the next steps, a rerun changes nothing, and a malformed bundle ID, an unknown --provider and an unknown --environment fail.
758419f to
461f4de
Compare
The mock keeps providers and platforms in a volume that docker compose down leaves in place, so a fixed project made every run after the first see the earlier run's providers and fail its first-run checks.
…PLE_HOST The e2e tests run init apns against a mock of Apple, so the sign-in, App Store Connect and Developer portal hosts can all be set to one base URL. Unset, they stay Apple's servers.
The mock API gains Apple's sign-in, session, team, key and App ID endpoints under /apple, kept per Apple ID. The harness signs in with an Apple ID and password, creates the key and registers the App ID, then reuses the saved sign-in to check the App ID on a rerun, turn on Push Notifications for an existing App ID, and create keys until the team has no free slot.
…ns-apple-e2e test(cli): e2e for init apns against a mock of Apple
APPWRITE_APPLE_HOST could send an Apple ID and password to any server from the shipped CLI. It now lives in a file built only with the e2e tag, which the CLI e2e suite passes; release builds always talk to Apple.
The override is no longer generated into the SDK. Like the conformance harness, it lives under tests/e2e/languages/cli and CLIGo126Test copies it into the generated CLI before building, so released SDKs never contain it.
…ns-e2e test(cli): e2e for init apns against the mock API and a mock of Apple
What does this PR do?
Adds
appwrite init apns, which sets up Appwrite Push for an iOS app. It creates the APNs providers, sets up the Xcode project, checks the App ID with Apple, and, if wanted, creates the APNs key itself by signing in with the Apple ID.It's the APNs half of #1963 and #2006, on its own branch from
main, so it can merge without the FCM work.init fcm(#1956) is blocked on permissions and stays separate. There's noinit push; the two commands run separately.What's in it
appwrite init apnsaps-environmententitlement and theremote-notificationbackground mode to the Xcode target.init apnsdoesn't set up: the Appwrite push provider when the project has none enabled (messages travel over it; APNs only wakes the app), and the Notification Service Extension with its App Group, for delivery while the app is in the background or swiped away.TopicDisallowed). It uses a key's fresh sign-in or a saved one, and asks before signing in or changing anything.--register-app-idmakes the changes without asking.--create-key@expo/apple-utils) and fastlane (spaceship). Picked with--providerorAPPWRITE_APNS_SETUP. If Apple's private API breaks one, users switch instead of waiting for a release.Usage
iOS app with a key in the project folder
The bundle ID and team come from the Xcode project or
app.json, and the key ID from theAuthKey_<KEYID>.p8file name, so nothing is asked:A key you already have
appwrite init apns --key-path ~/keys/AuthKey_Q4GAU66T2N.p8 --team-id ABCDE12345Create the key with the Apple ID
~/.appwrite/apns/<setup>/(0600). Later runs skip the password and two-factor until Apple expires it.--create-key, the same option is offered when no key is found, next to creating the key in the browser or picking a file.Only one environment
Register the App ID without being asked
Without a terminal (CI)
APPWRITE_APPLE_IDandAPPWRITE_APPLE_PASSWORDanswer the Apple ID and password, but the two-factor code always needs a terminal. In CI, pass--key-path. The App ID check then reports that it was skipped and why, and doesn't fail the command unless--register-app-idwas passed.Flags
--bundle-id <id>PRODUCT_BUNDLE_IDENTIFIERof the app target, or Expoios.bundleIdentifier. With several apps, a picker; with none, asked.--team-id <id>DEVELOPMENT_TEAM, Expoios.appleTeamId, or the team on an existing provider. With--create-key, the Apple sign-in picks it.--key-path <file>.p8).p8in the project folder. Otherwise asked: create one with the Apple ID, create it in the browser, or use a file.--key-id <id>AuthKey_<KEYID>.p8file name, otherwise asked. A created key uses Apple's ID.--create-key--provider <setup>appwrite,expoorfastlane$APPWRITE_APNS_SETUP, thenappwrite--environment <env>production,sandboxorallall--reset--create-key)--register-app-id--force(global)--create-keyand--resetcan't be combined with--key-pathor--key-id.APPWRITE_APNS_SETUPappwrite,expo,fastlane)APPWRITE_APPLE_IDAPPWRITE_APPLE_PASSWORDTest Plan
go vet,gofmtandgo testfor the whole generated CLI, including theinternal/apnssetups and theinit apnstests; the Generation suite, Rector and Twig lint.Results: detection, sandbox-only and both-environment setups, re-runs updating providers without duplicates, and the Xcode edits all work.
Bad input:
--bundle-id,--team-idor--key-id;.p8key;--provideror--environment;Each fails before anything is written.
Without a terminal: all three setups give the same message.
Related PRs and Issues
init fcm) stays separate, and rebases onto this once it's unblocked.