# เริ่มต้นใช้งาน Flutter SDK อย่างรวดเร็ว

เริ่มต้นใช้งาน Pushwoosh Flutter SDK ด้วยตัวอย่างที่ง่ายและรวดเร็วนี้

## ข้อกำหนดเบื้องต้น

ในการผสาน Pushwoosh Flutter SDK เข้ากับแอปของคุณ คุณจะต้องมีสิ่งต่อไปนี้:

<TranslatedFragment id="prerequisites-plugins" />

## ดาวน์โหลดโปรเจกต์ตัวอย่าง

```bash
# โคลน repository ของ SDK และไปที่โปรเจกต์ตัวอย่าง
git clone https://github.com/Pushwoosh/pushwoosh-flutter

# ไปที่ไดเรกทอรี example
cd pushwoosh-flutter/Source/pushwoosh/example
```

## กำหนดค่าโปรเจกต์

ติดตั้ง dependency:

```bash
flutter pub get
```

เปิด **lib/main.dart** และอัปเดตการเรียก `Pushwoosh.initialize`:

```dart
Pushwoosh.initialize({"app_id": "XXXXX-XXXXX"});
```

แทนที่ค่า `app_id` ด้วย **Pushwoosh App Code** ของคุณ

### iOS

###### 1. ติดตั้ง dependency

ไปที่ไดเรกทอรี `ios` และติดตั้ง dependency:

```bash
cd ios && pod install --repo-update
```

###### 2. ตั้งค่า Bundle Identifier

เปิดไฟล์ **ios/Runner.xcworkspace** ใน Xcode

ตั้งค่า **Bundle Identifier** สำหรับแต่ละ target:

- `Runner`: ชื่อแพ็กเกจของแอปของคุณ (เช่น `com.example.pushwoosh`)
- `NotificationService`: ชื่อแพ็กเกจของแอปของคุณพร้อมด้วย `.NotificationServiceExtension` (เช่น `com.example.pushwoosh.NotificationServiceExtension`)
- `StopwatchWidgetExtension`: ชื่อแพ็กเกจของแอปของคุณพร้อมด้วย `.StopwatchWidget` (เช่น `com.example.pushwoosh.StopwatchWidget`)

###### 3. ตั้งค่า API Token

ในไฟล์ `ios/Runner/Info.plist` ของคุณ ให้ตั้งค่าคีย์ `Pushwoosh_API_TOKEN` เป็น [Pushwoosh Device API Token](/th/developer/api-reference/api-access-token/#device-api-token)



### Android

###### 1. ตั้งค่า google-services.json

คัดลอกไฟล์ `google-services.json` ของคุณไปยังไดเรกทอรี **android/app**

###### 2. ตั้งค่าชื่อแพ็กเกจ

เปิด **android/app/build.gradle** และตั้งค่า **applicationId** เป็นชื่อแพ็กเกจของแอปของคุณ (เช่น `com.example.pushwoosh`)

###### 3. ตั้งค่า API Token

เปิดไฟล์ **android/app/src/main/AndroidManifest.xml** ของคุณและเพิ่ม metadata ต่อไปนี้ภายในแท็ก `<application>`:

```xml title="AndroidManifest.xml"
<meta-data android:name="com.pushwoosh.apitoken" android:value="__YOUR_PUSHWOOSH_DEVICE_API_TOKEN__" />
```
แทนที่ `__YOUR_PUSHWOOSH_DEVICE_API_TOKEN__` ด้วย [Pushwoosh Device API Token](/th/developer/api-reference/api-access-token/#device-api-token) ของคุณ


## รันโปรเจกต์

1. บิลด์และรันโปรเจกต์
2. แอปจะมีสองแท็บ: "Actions" และ "Settings" ไปที่แท็บ **Settings**
3. แตะปุ่ม **Register for Pushes**
4. ให้สิทธิ์สำหรับการแจ้งเตือนแบบพุช อุปกรณ์จะถูกลงทะเบียนกับ Pushwoosh

## ส่งการแจ้งเตือนแบบพุช

กลับไปที่ Pushwoosh Control Panel และ [ส่งการแจ้งเตือนแบบพุช](/th/product/messaging-channels/push-notifications/send-push-notifications/one-time-push) ไปยังอุปกรณ์ที่ลงทะเบียนของคุณ