# Magic Notifications

**In-app and push, through one facade.**

In-app database notifications and OneSignal push for the Magic framework, with polling, realtime delivery, user preferences and a CLI.

## Two channels. One facade.

Notifications for a Magic app go through `Notify`: an in-app database channel and OneSignal push. A backend is required; the docs include a Laravel setup guide.

### In-app database channel

`Notify.notifications()` streams the user's notifications and `Notify.markAsRead(id)` marks one as read, through `NotificationManager`.

[Learn more about In-app database channel](https://anilcancakir.com/magic/docs/notifications/basics/channels.md)

### OneSignal push

Push on iOS, Android and the web, with a soft prompt before the system prompt. `PushReachability` is `unavailable`, `blocked`, `off` or `on`; elsewhere push is absent.

[Learn more about OneSignal push](https://anilcancakir.com/magic/docs/notifications/basics/drivers.md)

### Polling you control

Use `Notify.startPolling()`, `stopPolling()`, `pausePolling()` and `resumePolling()`. Your app starts it; the interval is `notifications.database.polling_interval`.

[Learn more about Polling you control](https://anilcancakir.com/magic/docs/notifications/architecture/notification-manager.md)

### Realtime delivery

`Notify.startRealtime()` delivers notifications over a socket through magic_socket, on the `notification.created` event.

[Learn more about Realtime delivery](https://anilcancakir.com/magic/docs/notifications/architecture/notification-manager.md)

### User preferences

`NotificationPreferencesView` is a ready preferences screen, with a controller and a model for per-user preferences.

[Learn more about User preferences](https://anilcancakir.com/magic/docs/notifications/basics/preferences.md)

### Installer and doctor

A dowel CLI with `notifications:install` and a doctor, plus two read-only MCP tools for AI tools: `notifications_doctor` and `notifications_channels`.

[Learn more about Installer and doctor](https://anilcancakir.com/magic/docs/notifications/basics/cli.md)

## Add it in seconds

```bash
flutter pub add magic_notifications
```

Or add to `pubspec.yaml`:

```yaml
dependencies:
  magic_notifications: ^1.0.1
```

Or give your AI agent this prompt:

```text
Read https://anilcancakir.com/magic/docs/notifications/llms.txt and install the Magic Notifications package in this project.
```

## Docs

### Getting Started

- [Installation](https://anilcancakir.com/magic/docs/notifications/getting-started/installation.md)
- [Configuration](https://anilcancakir.com/magic/docs/notifications/getting-started/configuration.md)

### The Basics

- [Channels](https://anilcancakir.com/magic/docs/notifications/basics/channels.md)
- [Drivers](https://anilcancakir.com/magic/docs/notifications/basics/drivers.md)
- [Preferences](https://anilcancakir.com/magic/docs/notifications/basics/preferences.md)
- [Laravel Backend Setup](https://anilcancakir.com/magic/docs/notifications/basics/laravel-backend-setup.md)
- [Shipping push in a release build](https://anilcancakir.com/magic/docs/notifications/basics/shipping-push.md)
- [CLI Reference](https://anilcancakir.com/magic/docs/notifications/basics/cli.md)
- [Notification Dropdown](https://anilcancakir.com/magic/docs/notifications/basics/notification-dropdown.md)

### Architecture

- [Notification Manager](https://anilcancakir.com/magic/docs/notifications/architecture/notification-manager.md)
- [Service Provider](https://anilcancakir.com/magic/docs/notifications/architecture/service-provider.md)
