# Getting Started

**Purpose:** Step-by-step installation and setup guide for Daily Notification Plugin.  
**Owner:** Development Team  
**Last Updated:** 2025-12-22  
**Status:** active

---

## Installation

### npm

```bash
npm install @timesafari/daily-notification-plugin
```

### yarn

```bash
yarn add @timesafari/daily-notification-plugin
```

### pnpm

```bash
pnpm add @timesafari/daily-notification-plugin
```

---

## Platform Setup

### iOS

1. **Add to `Info.plist`:**

```xml
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
  <string>org.timesafari.dailynotification.fetch</string>
</array>
```

2. **Register background task in `AppDelegate.swift`:**

```swift
import BackgroundTasks

func application(_ application: UIApplication, 
                didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  BGTaskScheduler.shared.register(forTaskWithIdentifier: "org.timesafari.dailynotification.fetch", 
                                  using: nil) { task in
    // Handle background fetch task
  }
  return true
}
```

### Android

1. **Add permissions to `AndroidManifest.xml`:**

```xml
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
```

> **Note on `USE_EXACT_ALARM`:** The `USE_EXACT_ALARM` permission is restricted
> by Google on Android. Apps that declare it must be primarily dedicated to alarm
> or calendar functionality. Google will reject apps from the Play Store that use
> this permission for other purposes. This plugin uses `SCHEDULE_EXACT_ALARM`
> instead, which is sufficient for scheduling daily notifications.

2. **Register WorkManager in `Application.kt`:**

```kotlin
import androidx.work.Configuration
import androidx.work.WorkManager

class MyApplication : Application() {
  override fun onCreate() {
    super.onCreate()
    WorkManager.initialize(
      this,
      Configuration.Builder()
        .setMinimumLoggingLevel(android.util.Log.INFO)
        .build()
    )
  }
}
```

---

## Basic Usage

### 1. Import the Plugin

```typescript
import { DailyNotification } from '@timesafari/daily-notification-plugin';
```

### 2. Request Permission

```typescript
const { state } = await DailyNotification.requestPermission();
if (state !== 'granted') {
  console.error('Notification permission denied');
  return;
}
```

### 3. Create a Schedule

```typescript
const { schedule } = await DailyNotification.createSchedule({
  id: 'morning-notification',
  kind: 'notify',
  clockTime: '09:00',
  enabled: true
});
```

### 4. Verify Schedule

```typescript
const { schedules } = await DailyNotification.getSchedules();
console.log('Active schedules:', schedules);
```

---

## Next Steps

- **[Quick Start Guide](./examples/QUICK_START.md)** — Minimal working example
- **[Common Patterns](./examples/COMMON_PATTERNS.md)** — Common integration patterns
- **[Integration Guide](./integration/INTEGRATION_GUIDE.md)** — Full integration guide
- **[Troubleshooting](./TROUBLESHOOTING.md)** — Common issues and solutions

---

## Authoritative Documentation

- **[Documentation Index](./00-INDEX.md)** — Complete documentation navigation
- **[System Invariants](./SYSTEM_INVARIANTS.md)** — Enforced system invariants
- **[CI Usage](../ci/README.md)** — Local CI documentation (`./ci/run.sh`)

---

## Support

For issues, questions, or contributions:

1. Check [Troubleshooting Guide](./TROUBLESHOOTING.md)
2. Review [System Invariants](./SYSTEM_INVARIANTS.md)
3. Check [Progress Documentation](./progress/00-STATUS.md) for current status

---

**See also:**
- [README.md](../README.md) — Complete plugin documentation
- [Performance Characteristics](./PERFORMANCE.md) — Performance expectations

