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

# Notification System

> Understanding push notifications and messaging

# Notification System

Twigz provides a comprehensive notification system for real-time communication.

## Notification Types

### 1. **Order Notifications**

* New order received
* Order status updates
* Payment confirmations
* Delivery notifications

### 2. **Store Notifications**

* New customer reviews
* Low inventory alerts
* Payout notifications
* System updates

### 3. **Customer Notifications**

* Order updates
* Price changes
* New products from followed stores
* Social interactions

### 4. **Admin Notifications**

* Store approval requests
* Payout processing
* System alerts
* Moderation flags

## Push Notification Setup

### FCM (Firebase Cloud Messaging)

```typescript theme={null}
// Record device token
await convex.mutation(api.shared.notifications.recordNativeDeviceToken, {
  token: "fcm_token_here",
  platform: "android"
});
```

### APNs (Apple Push Notifications)

```typescript theme={null}
// Record iOS device token
await convex.mutation(api.shared.notifications.recordNativeDeviceToken, {
  token: "apns_token_here", 
  platform: "ios"
});
```

## Sending Notifications

### Direct FCM

```typescript theme={null}
await convex.mutation(api.shared.notifications.sendFCMNotificationDirect, {
  token: "device_token",
  title: "New Order!",
  body: "You have received a new order",
  data: { orderId: "order_123" }
});
```

### Direct APNs

```typescript theme={null}
await convex.mutation(api.shared.notifications.sendAPNsNotificationDirect, {
  token: "device_token",
  title: "Order Update",
  body: "Your order status has changed",
  data: { orderId: "order_123" }
});
```

## Notification Features

### Scheduled Notifications

* Send notifications at specific times
* Recurring notifications
* Timezone-aware scheduling

### Bulk Notifications

* Send to multiple users
* Targeted notifications
* A/B testing support

### Notification History

* Track all sent notifications
* Delivery status monitoring
* Analytics and insights

## Best Practices

1. **Personalization**: Use customer data for relevant notifications
2. **Timing**: Send notifications at appropriate times
3. **Frequency**: Don't overwhelm users with too many notifications
4. **Content**: Keep messages clear and actionable
5. **Testing**: Always test notifications before sending

<Note>
  The notification system supports both FCM and APNs for maximum compatibility across platforms.
</Note>
