iOS: emit aps-environment entitlement for push notifications (#5074)#5121
Conversation
registerForRemoteNotifications always failed on Perry-built iOS apps because the signed .app never carried the aps-environment entitlement, so iOS responded with didFailToRegisterForRemoteNotificationsWithError and no APNs device token was produced. The runtime side was already complete; the only gap was the entitlement. Add an opt-in perry.toml switch: [ios] push_notifications = true # emit aps-environment # push_environment = "production" # default "development" - inject_ios_push_entitlement writes aps-environment into the bundle's app.entitlements during `perry compile --target ios`, defaulting to development and clamping unknown push_environment values back to it. Idempotent with the deeplinks (#583) and App Group (#1178) passes. - build_dev_entitlements_xml already layers dev signing keys on top of the compile-emitted entitlements, so push survives `perry run` resign (new regression test). - create_dev_profile_via_api enables the PUSH_NOTIFICATIONS capability on the App ID (best-effort, mirroring App Groups) when opted in; wired through both `perry setup ios` and `perry run --target ios`. Docs: notifications.md gains an "Enabling APNs on iOS" section. Tests: 8 new unit tests across apple_info_plist.rs and resign.rs. https://claude.ai/code/session_017TRpeWZrkdbBwpmGQb7eXE
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdds end-to-end iOS push notification support controlled by ChangesiOS Push Notification Entitlement Pipeline
Sequence DiagramsequenceDiagram
participant Developer
participant perry_compile as perry compile --target ios
participant inject_ios_push_entitlement
participant perry_setup as perry setup ios
participant create_dev_profile_via_api
participant AppStoreConnect as App Store Connect API
rect rgba(99, 179, 237, 0.5)
Note over Developer, inject_ios_push_entitlement: Build path
Developer->>perry_compile: perry.toml [ios] push_notifications=true
perry_compile->>inject_ios_push_entitlement: input path, app_dir, format
inject_ios_push_entitlement->>inject_ios_push_entitlement: read_ios_push_config → (enabled, environment)
inject_ios_push_entitlement->>inject_ios_push_entitlement: idempotent splice/create app.entitlements
end
rect rgba(154, 230, 180, 0.5)
Note over Developer, AppStoreConnect: Provisioning path
Developer->>perry_setup: perry.toml [ios] push_notifications=true
perry_setup->>create_dev_profile_via_api: push_notifications=true
create_dev_profile_via_api->>AppStoreConnect: enable PUSH_NOTIFICATIONS capability on App ID
AppStoreConnect-->>create_dev_profile_via_api: 200 OK or 409 (already enabled)
create_dev_profile_via_api->>create_dev_profile_via_api: mint provisioning profile
create_dev_profile_via_api-->>perry_setup: profile bytes
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Fixes #5074.
Problem
registerForRemoteNotifications(notificationRegisterRemoteinperry/system) always failed on Perry-built iOS apps. The runtime side was already complete — the registration call plus thedidRegister…DeviceTokendelegate wiring inperry-ui-ios— but the signed.appnever carried theaps-environmententitlement, so iOS responded withdidFailToRegisterForRemoteNotificationsWithErrorand no APNs device token was ever produced. There was noperry.tomlkey to request it.Fix
New opt-in switch in
perry.toml:inject_ios_push_entitlement(apple_info_plist.rs) writesaps-environmentinto the bundle'sapp.entitlementsduringperry compile --target ios. Defaults todevelopment(matching the dev-signed bundles compile produces);push_environment = "production"overrides it for App Store / Ad Hoc distribution, and any other value clamps back todevelopment. Idempotent with the deeplinks (Deep links: Universal Links (iOS) + App Links (Android) + URL-scheme open handling #583) and App Group (appGroupSet/Get/Delete on iOS is an in-process HashMap stub — wire UserDefaults(suiteName:) (follow-up to #675) #1178) entitlement passes — splices the key into an existingapp.entitlementsrather than clobbering it, and leaves a hand-writtenaps-environmentalone.build_dev_entitlements_xmlalready layers the development signing keys on top of the compile-emittedapp.entitlements, so the push entitlement survivesperry run --target iosre-signing (new regression test).create_dev_profile_via_apinow enables thePUSH_NOTIFICATIONScapability on the App ID (best-effort, mirroring the App Groups toggle) when[ios] push_notifications = true. Wired through bothperry setup iosandperry run --target ios.Docs / tests
docs/src/system/notifications.mdgains an "Enabling APNs on iOS" section.apple_info_plist.rsandresign.rs; fullperrysuite green (543 passed), release build succeeds.https://claude.ai/code/session_017TRpeWZrkdbBwpmGQb7eXE
Generated by Claude Code
Summary by CodeRabbit
Release Notes
New Features
push_notifications = truein project configuration to enable APNs.Documentation