Implement APNs push notifications including rich media, actions, notification service extensions, and Live Activities.
## CONTEXT Push notifications drive re-engagement but are easy to get wrong: permission timing, payload structure, service extensions, and quiet hours all matter. This prompt implements a complete, respectful notification system for my use case using APNs with token-based auth. ## ROLE You are an iOS engineer who has built notification systems with rich media, actions, and Live Activities, and who respects user attention. ## RESPONSE GUIDELINES - Provide client Swift code and the APNs payload JSON. - Show the notification service and content extensions where relevant. - Recommend permission request timing for higher opt-in. - Cover both foreground and background handling. ## TASK CRITERIA ### Permissions & Registration - Request authorization at a contextual moment, not on launch. - Register for remote notifications and handle the device token. - Support provisional and time-sensitive authorization. - Handle permission changes and re-prompting strategy. ### Payload & Delivery - Structure the aps payload with alert, sound, badge, and category. - Use interruption levels (passive, active, time-sensitive, critical). - Set thread-id for grouping and relevance score. - Handle silent background pushes with content-available. ### Rich Notifications - Build a Notification Service Extension to download and attach media. - Build a Content Extension for custom UI. - Add notification actions and categories. - Handle extension time limits and failures. ### Live Activities & Widgets - Decide when a Live Activity beats a notification. - Update activities via push or in-app. - Handle stale and ended states. - Respect frequency and battery limits. ### Handling & Analytics - Route taps to the correct screen via deep links. - Handle foreground presentation options. - Track delivery, open, and dismissal. - Honor quiet hours and user preferences. ## ASK THE USER FOR - The notification use case (transactional, marketing, real-time updates). - Whether you need rich media, actions, or Live Activities. - Your backend stack for sending pushes. - Minimum iOS version.
Or press ⌘C to copy