# Add Local Notifications to a Flutter App

Yes. An agent adds flutter_local_notifications with the Android and iOS setup it needs, routes a tap to your messages page, runs analyze and test, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-local-notifications/flutter/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the repository into its own cloud sandbox and reads how the app starts and where a notification would land. In a Flutter app like simplezhli/flutter_deer, `pubspec.yaml` asks for Dart 3.4 and Flutter 3.19 or later, already pulls in `quick_actions`, `device_info_plus` and `window_manager`, and has no notification package. `lib/main.dart` builds `MyApp`, whose constructor runs `Log.init()`, `initDio()`, `Routes.initRoutes()` and `initQuickActions()`, keeps a static `navigatorKey`, and guards mobile-only code with `Device.isMobile` from `lib/util/device_utils.dart`. The app already has a messages screen, `MessagePage` in `lib/shop/page/message_page.dart`, registered as `/shop/message` in `lib/shop/shop_router.dart`, so a tapped notification has somewhere to go. On Android, `AndroidManifest.xml` declares `INTERNET` and `REQUEST_INSTALL_PACKAGES`, `MainActivity` is `singleTop`, and `android/app/build.gradle` targets SDK 37 with Java 17 but no core library desugaring; on iOS, `AppDelegate.swift` already implements `didInitializeImplicitFlutterEngine` to register plugins and a `version` method channel.

It adds the plugin and a thin wrapper. `flutter_local_notifications` goes into `pubspec.yaml` with `timezone` as a direct dependency, since scheduled notifications need it. A new `lib/util/notification_utils.dart` initialises the plugin once with `AndroidInitializationSettings` pointing at a small monochrome drawable the agent adds under `android/app/src/main/res/drawable`, and `DarwinInitializationSettings` with the three permission prompts turned off so the app can ask at a better moment; `onDidReceiveNotificationResponse` pushes `ShopRouter.messagePage` through `MyApp.navigatorKey`, and a `show(id, title, body, payload)` helper wraps a notification channel for order updates with high importance. `MyApp`'s constructor calls the initialiser beside `initQuickActions()` under `Device.isMobile`, and a `requestPermission()` helper calls the Android 13 `requestNotificationsPermission` and the iOS `requestPermissions` so the prompt can be tied to a user action such as opening the messages page.

The platform edits are the part most pull requests get wrong, so the agent does them from the plugin's own setup notes. In `android/app/build.gradle` it enables `coreLibraryDesugaringEnabled` under `compileOptions` and adds the `desugar_jdk_libs` dependency the plugin requires, and in `AndroidManifest.xml` it adds the two receivers for scheduled notifications so a reminder survives a reboot. In `AppDelegate.swift` it sets `UNUserNotificationCenter.current().delegate` in `didFinishLaunchingWithOptions` and, because this app already uses the implicit-engine delegate, puts the plugin registrant callback in `didInitializeImplicitFlutterEngine` where `GeneratedPluginRegistrant.register` already runs. The macOS, Windows and web targets in the repository are untouched; the wrapper only runs where `Device.isMobile` is true.

Before opening anything it proves the change. It installs the Flutter version the repository's own workflow uses, `3.47.4` in `.github/workflows`, runs `flutter pub get`, `flutter analyze` and `flutter test`, where `test/widget_test.dart` already pumps `MessagePage`, and adds a unit test that checks the wrapper maps a payload to the messages route. It then installs the Android command-line tools and runs `flutter build apk --debug`, because the desugaring change lives in Gradle and only a build shows it is right. Every command and its output goes into the pull request.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add local notifications to this Flutter app. Read pubspec.yaml, lib/main.dart, lib/util/device_utils.dart, lib/routers/routers.dart, lib/shop/shop_router.dart, lib/shop/page/message_page.dart, android/app/build.gradle, android/app/src/main/AndroidManifest.xml, ios/Runner/AppDelegate.swift and the workflows under .github/workflows first, and confirm there is no notification package today. Add flutter_local_notifications and timezone, write a NotificationUtils wrapper in lib/util that initialises the plugin on mobile only, exposes show and requestPermission helpers, and opens the existing messages page when a notification is tapped. Make the Android and iOS changes the plugin's setup requires: core library desugaring in build.gradle, the scheduled-notification receivers in the manifest, the notification center delegate and the plugin registrant callback in AppDelegate.swift placed where this app registers plugins. Add a small monochrome notification icon. Do not touch the desktop or web targets. In your sandbox install the Flutter version the workflow pins, run flutter pub get, flutter analyze and flutter test, add a unit test for the tap routing, install the Android command-line tools and run flutter build apk --debug, and open a pull request that lists the files changed, where to call requestPermission, and the command output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request touching `pubspec.yaml`, `pubspec.lock`, `lib/main.dart`, a new `lib/util/notification_utils.dart`, `android/app/build.gradle`, `android/app/src/main/AndroidManifest.xml`, a new drawable, `ios/Runner/AppDelegate.swift` and one new test. The description explains the wrapper's three calls, says which line of `MyApp` initialises it, and tells the team where to call `requestPermission` so the system prompt appears when a user has a reason to expect it.

The run's record holds the `flutter analyze`, `flutter test` and `flutter build apk --debug` output from the sandbox, so a reviewer can see the Gradle change compiled with desugaring on before pulling the branch, and every file the agent read before deciding to route taps to the existing messages page.

Before merging, a reviewer runs the app on a physical Android 13 or newer device and on an iOS device, since a sandbox cannot show the permission prompt or the notification tray, and decides what the first real trigger is: an order status change from the network layer, a scheduled reminder, or both.

## Run it on every Linear issue labelled mobile

A team that tracks app work in Linear starts one run per issue from an automation with a `linear` trigger on the `mobile` label, in the Project that holds the Flutter repository. The trigger adds the issue after this prompt and fills in no placeholder, so an issue that asks for a reminder at a set time, a different channel per order state, or a badge count is what the agent reads and builds.

Each run clones the app into its own sandbox, installs the pinned Flutter version and the Android tools there, and opens its own pull request linking the issue. An automation run has its own `max_runs_per_hour` cap, and a second issue labelled in the same hour gets its own sandbox as long as that cap allows; a fire past the cap is skipped, not queued.

## Why run it on Rush?

Local notifications are one Dart file and four platform edits, and the platform edits are where things break: desugaring missing from Gradle, a receiver missing from the manifest, a delegate set in the wrong AppDelegate method. The agent reads the plugin's setup notes and the app's actual `build.gradle` and `AppDelegate.swift` in the same run, and then builds the Android app to show the Gradle change holds, so the pull request arrives already compiled rather than with a build error waiting in CI.

The sandbox installs the exact Flutter version the repository's workflow pins and the Android command-line tools from scratch, work a laptop with a different Flutter channel cannot reproduce. The same request runs against every Flutter app an organisation ships, each with its own routes and platform files read first, and each pull request keeps the full command record.

## Frequently asked questions

### Does this send push notifications from a server?

No. Local notifications are created by the app on the device, which is enough for reminders and for events the app already learns about through its own network calls. Push from a server needs Firebase Cloud Messaging or APNs and its own credentials, which this change does not add.

### Why does Android need desugaring?

The plugin uses Java 8 APIs that older Android runtimes lack, so it requires core library desugaring to be turned on in `build.gradle` along with the `desugar_jdk_libs` dependency. Without it the plugin's setup notes say the build fails, which is why the agent builds a debug APK in its sandbox.

### When is the permission prompt shown?

Not at startup. The wrapper initialises with the iOS prompts turned off and never asks on Android until `requestPermission` is called, so the team can call it from the messages page or after the first order, where a user understands why. Android 13 and later needs that runtime request before any notification appears.

### What happens when a user taps the notification?

The tap handler reads the payload and pushes the existing `/shop/message` route through the app's navigator key, so the user lands on the messages screen. A payload that names an order can be routed to the order detail page instead with one more branch, which the pull request points out.

### Does it affect the desktop and web builds?

The initialiser only runs where `Device.isMobile` is true, and the wrapper does nothing elsewhere. The plugin itself supports macOS, Linux and Windows, so extending it later means removing that guard and adding the per-platform settings.

## More Flutter jobs

- [Add a Native Splash Screen to a Flutter App](https://getrush.ai/run/add-splash-screen/flutter/)
- [Replace Deprecated Flutter APIs Across an App and Make the Analyzer Catch the Next Ones](https://getrush.ai/run/fix-deprecated-apis/flutter/)
- [Fix Flutter Errors from Sentry Alerts](https://getrush.ai/run/fix-sentry-errors/flutter/)

## More jobs like this: Turn a Linear label into a PR

- [Set Lambda Log Retention in an AWS CDK Stack](https://getrush.ai/run/add-log-retention/aws-cdk/)
- [Set CloudWatch Log Retention in a Serverless Framework Service](https://getrush.ai/run/add-log-retention/serverless/)
- [Add macOS Code Signing and Notarization to a Tauri Release Workflow](https://getrush.ai/run/add-macos-code-signing/tauri/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
