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

# Notifications

> Send and manage push notifications through adapter-based providers

# @amisi/notifications

`@amisi/notifications` provides an adapter-based notifications API so you can switch providers without changing screen-level logic.

## Adapter model

* **Contract**
  * Providers implement the shared `NotificationAdapter` contract.

* **Runtime selection**
  * Select the active adapter at runtime using `initializeNotifications({ adapter, options })`.

* **Built-in adapters**
  * `onesignal`
  * `expo`
  * `mock`

## Initialize

Initialize notifications once at app startup.

The starter app initializes notifications in `apps/mobile/app/_layout.tsx` using `amisi.config.json`.

## Request permission

Use the hook in screens/components:

```tsx theme={null}
import { useNotifications } from '@amisi/notifications';

export function PermissionsScreen() {
  const notifications = useNotifications();

  const handleEnable = async () => {
    const status = await notifications.requestPermission();

    if (!status.granted) {
      return;
    }

    await notifications.registerForPush('user-123');
  };

  return null;
}
```

## Manage notification preferences

Persist user preferences using the same hook:

```tsx theme={null}
import { useNotifications } from '@amisi/notifications';

export function ProfileScreen() {
  const notifications = useNotifications();

  const handleChange = async () => {
    await notifications.setPreferences({
      push: true,
      emailDigest: false,
      smsAlerts: true,
    });
  };

  return null;
}
```

## OneSignal configuration

For OneSignal, configure the app and plugin setup in:

* `amisi.config.json` (`notifications.adapter` and optional options)
* `apps/mobile/app.json` (`onesignal-expo-plugin`)

The current default adapter is `onesignal`.

## Expo notifications configuration

If you select the `expo` adapter, keep native Expo notification permissions and credentials configured for iOS and Android builds.
