# เริ่มต้นใช้งาน Unity SDK ฉบับย่อ

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

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

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

<TranslatedFragment id="prerequisites-plugins-unity" />

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

โคลน repository ของโปรเจกต์ตัวอย่าง:

```bash
git clone https://github.com/Pushwoosh/pushwoosh-unity-sample.git
```

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

เปิด **Assets/Scripts/PushNotificator.cs** และตั้งค่าการเริ่มต้นของ Pushwoosh:

```csharp title="Assets/Scripts/PushNotificator.cs"
Pushwoosh.ApplicationCode = "XXXXX-XXXXX";
Pushwoosh.FcmProjectNumber = "XXXXXXXXXXXX";
```

แทนที่ค่า `ApplicationCode` และ `FcmProjectNumber` ด้วย **Pushwoosh App Code** และ **Firebase Project Number** ของคุณ

### iOS

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

ใน Unity ไปที่ **Edit > Project Settings > Player > iOS > Other Settings** และตั้งค่า **Bundle Identifier** เป็น bundle ID ของคุณ (เช่น `com.example.pushwoosh`)

###### 2. Build และติดตั้ง dependencies

Build โปรเจกต์ iOS จาก Unity จากนั้นไปที่ไดเรกทอรีโปรเจกต์ Xcode ที่สร้างขึ้นและติดตั้ง dependencies ของ CocoaPods:

```bash
cd ios && pod install
```

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

เปิดไฟล์ **ios/Unity-iPhone.xcworkspace** ใน Xcode
ใน `Info.plist` ของคุณ เพิ่ม [Pushwoosh Device API Token](/th/developer/api-reference/api-access-token/#device-api-token):

```xml title="Info.plist"
<key>Pushwoosh_API_TOKEN</key>
<string>__PUSHWOOSH_DEVICE_API_TOKEN__</string>
```

### Android

###### 1. ตั้งค่า package name

ใน Unity ไปที่ **Edit > Project Settings > Player > Android > Other Settings** และตั้งค่า **Package Name** เป็น package name ของแอปของคุณ (เช่น `com.example.pushwoosh`)

###### 2. เพิ่ม google-services.json

คัดลอกไฟล์ `google-services.json` ของคุณไปยังไดเรกทอรี **Assets** ในโปรเจกต์ Unity ของคุณ

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

ใน `Assets/Plugins/Android/AndroidManifest.xml` ของคุณ เพิ่ม [Pushwoosh Device API Token](/th/developer/api-reference/api-access-token/#device-api-token) ภายในแท็ก `<application>`:

```xml title="AndroidManifest.xml"
<meta-data android:name="com.pushwoosh.apitoken" android:value="__YOUR_DEVICE_API_TOKEN__" />
```

<Aside type="caution">
ตรวจสอบให้แน่ใจว่าได้ให้สิทธิ์การเข้าถึงของ token กับแอปที่ถูกต้องใน Pushwoosh Control Panel ของคุณ [เรียนรู้เพิ่มเติม](/th/developer/api-reference/api-access-token/#edit-token)
</Aside>

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

1. Build และรันโปรเจกต์
2. แตะปุ่ม **Register for push notifications**
3. ให้สิทธิ์สำหรับ push notifications อุปกรณ์จะถูกลงทะเบียนกับ Pushwoosh

## ส่ง push notification

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