> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerix.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Flutter — Push Notifications

> Configure push notifications for Android, iOS, and Huawei on Flutter.

## Introduction

Atelerix delivers push notifications using each platform's native service — Firebase Cloud Messaging (FCM) on Android, and Apple Push Notification service (APNs) directly on iOS, no Firebase required. After you complete the [Flutter installation](/frameworks/flutter/installation), follow the platform steps below to enable push delivery in your app.

<Note>
  Make sure you have initialized the SDK with `Atelerix.init()` before configuring push notifications.
</Note>

## Android configuration

No additional SDK setup is required for Android. You only need to add your Firebase `google-services.json` file to the project.

1. Create or open your app in the [Firebase Console](https://console.firebase.google.com/).
2. Download `google-services.json` for your Android app.
3. Upload the file to the Atelerix dashboard.

For the full setup steps, see [Firebase's Android client setup guide](https://firebase.google.com/docs/cloud-messaging/android/client).

## iOS configuration

You need an active [Apple Developer account](https://developer.apple.com/programs/) to send push notifications on iOS.

### Set up APNs authentication

1. In the [Apple Developer portal](https://developer.apple.com/account/resources/authkeys/list), go to **Certificates, Identifiers & Profiles → Keys**.
2. Create a new key with **Apple Push Notifications service (APNs)** enabled.
3. Download the `.p8` authentication key and note the **Key ID**. You can only download the key once.
4. Upload the `.p8` file to the Atelerix dashboard.

For the full setup steps, see [Apple's guide to registering your app with APNs](https://developer.apple.com/documentation/usernotifications/registering-your-app-with-apns).

### AppDelegate configuration

Add the following overrides to `ios/Runner/AppDelegate.swift`:

```swift AppDelegate.swift theme={null}
import atelerix

override func application(
  _ application: UIApplication,
  didRegisterForRemoteNotificationsWithDeviceToken deviceData: Data
) {
  atelerix_didRegisterForRemoteNotifications(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceData)
}

override func application(
  _ application: UIApplication,
  didFailToRegisterForRemoteNotificationsWithError error: Error
) {
  atelerix_didFailToRegisterForRemoteNotifications(application, didFailToRegisterForRemoteNotificationsWithError: error)
}
```

## Huawei configuration

<Badge>Coming Soon</Badge>

Huawei push notification support is not available yet. Check back soon for setup instructions.

## Dashboard settings

Once you've uploaded your `google-services.json` (Android) and/or `.p8` key (iOS) from the project's **Notifications → Settings** tab in the dashboard, that platform card shows a **Configured** badge and the credentials it holds — click it again any time to review them or upload a replacement.

## Flutter code

All notification methods live on `Atelerix.notifications`, and require `await Atelerix.notifications.init()` to have run first — registration with APNs/FCM happens automatically as part of `init()`, so there's no separate "register" call for the normal flow.

```dart main.dart theme={null}
await Atelerix.notifications.init();

final granted = await Atelerix.notifications.requestPermissions();

Atelerix.notifications.setOnNotificationReceived((notification) {
  // Handle notification received while the app is open
});

Atelerix.notifications.setOnNotificationTapped((notification) {
  // Handle notification tap
});

final token = await Atelerix.notifications.getDeviceToken();
final status = await Atelerix.notifications.checkPermissionStatus();
// "authorized", "denied", "notDetermined"
```

## Topics

Instead of targeting specific device tokens, a device can subscribe to a named topic — send one notification to the topic and every subscriber receives it. A topic doesn't need to be created ahead of time; it's created automatically the first time any device subscribes to it. You can also view, create, and delete topics from the **Notifications → Topics** tab in the dashboard.

```dart theme={null}
final subscribed = await Atelerix.notifications.subscribeToTopic('promotions');

await Atelerix.notifications.unsubscribeFromTopic('promotions');
```

To send to a topic, use the dashboard's **Send notification** tab (select "Topic" as the audience), or call the [REST API](/api-reference/push-notifications) with `sendByTopic: true`.
