home / skills / hoangnguyen0403 / agent-skills-standard / ios-notifications

ios-notifications skill

/skills/ios/ios-notifications

This skill helps implement iOS push notifications using UserNotifications and APNs, including foreground handling and permissions workflow.

npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill ios-notifications

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1.2 KB
---
name: iOS Notifications
description: Push notifications for iOS using UserNotifications framework and APNS.
metadata:
  labels: [ios, apns, notifications, push, user-notifications]
  triggers:
    files: ['**/*Notification*.swift', '**/*AppDelegate.swift']
    keywords:
      [UNUserNotificationCenter, APNS, UNNotificationRequest, deviceToken]
---

# iOS Notifications

## **Priority: P2 (OPTIONAL)**

Push notifications using UserNotifications framework and APNs.

## Guidelines

- **Framework**: Use `UserNotifications` for all notification handling.
- **Delegate**: Implement `UNUserNotificationCenterDelegate` for foreground & tap handling.
- **Permissions**: Request `.alert`, `.badge`, `.sound` after priming the user.
- **APNs**: Register for remote notifications in `AppDelegate`.
- **Badges**: Manage app icon badges manually (set to 0 to clear).

[Implementation Details](references/implementation.md)

## Anti-Patterns

- **No Unconditional Requests**: Explain value proposition before system dialog.
- **No Missing Delegate**: Notifications won't trigger foreground callbacks without it.
- **No Forgotten Badge Clear**: User frustration increases if badges persist.

## Related Topics

ios-navigation | ios-design-system | mobile-ux-core

Overview

This skill documents best practices for implementing iOS push notifications using the UserNotifications framework and APNs. It focuses on correct setup, permission flow, delegate handling, and badge management to deliver reliable and user-friendly notifications. The guidance is practical and geared toward TypeScript/Swift hybrid projects and cross-platform teams.

How this skill works

It prescribes using UserNotifications for all local and remote notification handling and registering the app with APNs via AppDelegate. It requires implementing UNUserNotificationCenterDelegate to handle foreground presentation and user interactions. It also covers requesting permissions after priming users and manually managing app icon badges.

When to use it

  • When adding remote push notifications via APNs to an iOS app
  • When needing consistent foreground and tap behavior for notifications
  • When implementing badge count logic and badge clearing
  • When integrating notifications in cross-platform projects (React Native/Flutter)
  • When auditing notification-related anti-patterns and UX issues

Best practices

  • Use UserNotifications (UNUserNotificationCenter) as the single source for notification handling
  • Implement UNUserNotificationCenterDelegate to receive foreground presentation and tap callbacks
  • Prime the user with in-app UI before invoking the system permission dialog
  • Request .alert, .badge, .sound permissions—explain why each is needed
  • Register for remote notifications in AppDelegate and handle device token errors
  • Manage badges explicitly; set to 0 to clear when appropriate

Example use cases

  • Onboarding flow shows benefits of notifications, then prompts for permission
  • App receives APNs payload while foregrounded and displays a custom banner via delegate
  • Server sends badge counts; app clears or updates badges when user reads content
  • React Native or Flutter app delegates native notification handling to platform code following these rules
  • Background silent push triggers content refresh and local notification presentation when needed

FAQ

Do I need UNUserNotificationCenterDelegate?

Yes. Without the delegate, the app won’t receive foreground presentation callbacks or user tap handling reliably.

When should I request permissions?

Prime users with an in-app explanation of value, then call the system permission prompt. Avoid unconditional requests at first launch.