ตัวอย่างโค้ด iOS
ด้วยตัวอย่างของ Pushwoosh สำหรับ iOS คุณสามารถสำรวจฟังก์ชันการทำงานของ Pushwoosh ได้โดยไม่ต้องรวม SDK เข้ากับโปรเจกต์ของคุณ หรือตรวจสอบว่า Pushwoosh SDK ถูกนำไปใช้อย่างไรในโปรเจกต์ตัวอย่างของเรา
ข้อกำหนดเบื้องต้น
Anchor link toก่อนใช้ตัวอย่าง โปรดตรวจสอบให้แน่ใจว่าคุณมีสิ่งต่อไปนี้:
แอปพลิเคชันตัวอย่าง Pushwoosh
Anchor link toโปรเจกต์นี้เป็นแอปพลิเคชัน iOS พื้นฐานที่รวม Pushwoosh SDK ไว้ด้วย ซึ่งแสดงฟีเจอร์หลักต่างๆ เช่น:
- การรับการแจ้งเตือนแบบพุช
- การติดตามการส่งการแจ้งเตือนแบบพุช
- การจัดการแท็กผู้ใช้
- การส่งอีเวนต์
- การลงทะเบียนผู้ใช้
ใช้แอปตัวอย่างเป็นเครื่องมือในการเรียนรู้หรือเป็นรากฐานสำหรับการพัฒนาของคุณ
1. ดาวน์โหลดแอปตัวอย่าง
Anchor link toโคลน repository:
git clone https://github.com/Pushwoosh/pushwoosh-ios-sample.git2. กำหนดค่าโปรเจกต์
Anchor link toOpen the project in Xcode.
Add
https://github.com/Pushwoosh/Pushwoosh-XCFrameworkas Swift Package Dependency.Set the bundle identifier for the main target (PushwooshSampleApp) to match your Pushwoosh project (e.g.,
com.pushwoosh.PushwooshSampleApp).Use the same bundle identifier for the NotificationService target, appending
.NotificationService(e.g.,com.pushwoosh.PushwooshSampleApp.NotificationService).In
Info.plist, set the:Pushwoosh_APPIDkey to the Pushwoosh Application CodePushwoosh_API_TOKENkey to the Pushwoosh Device API Token
Important: Be sure to give the token access to the right app in your Pushwoosh Control Panel. Learn more
3. รันโปรเจกต์
Anchor link to- บิวด์และรันโปรเจกต์
- ไปที่แท็บ Settings ในแอป
- แตะปุ่ม Register for Pushes
- ให้สิทธิ์สำหรับการแจ้งเตือนแบบพุช อุปกรณ์จะถูกลงทะเบียนกับ Pushwoosh
แอปพลิเคชัน Quickstart ของ Pushwoosh
Anchor link toคอลเลกชัน Quickstart ประกอบด้วยโปรเจกต์แต่ละโปรเจกต์ ซึ่งแต่ละโปรเจกต์จะแสดงฟีเจอร์ SDK ที่เฉพาะเจาะจง ใช้สิ่งเหล่านี้เป็นข้อมูลอ้างอิงหรือเป็นจุดเริ่มต้นสำหรับแอปของคุณ
1. ดาวน์โหลดแอปพลิเคชัน Quickstart
Anchor link toโคลนโปรเจกต์ตัวอย่างจาก GitHub:
git clone https://github.com/Pushwoosh/pushwoosh-quickstart-ios.git2. สำรวจโปรเจกต์
Anchor link toแต่ละโฟลเดอร์มีโปรเจกต์ที่ปรับให้เหมาะกับฟีเจอร์เฉพาะ:
- Basic Integration
- Badges
- Custom Data Examples
- Customizing
- Delivery tracking
- Inbox Project
- Interactive Push
- Provisional Push Project
- Rich Notifications Project
- VoIP Pushes Project
3. กำหนดค่าและรัน
Anchor link to- เปิดโปรเจกต์ใน Xcode
- ตั้งค่า bundle identifier ให้ตรงกับโปรเจกต์ Pushwoosh ของคุณ
- คัดลอก Application Code จาก Pushwoosh Dashboard
- ใน
Info.plistตั้งค่าคีย์Pushwoosh_APPIDเป็น Application Code - บิวด์และรันโปรเจกต์
- ใช้ Pushwoosh Control Panel เพื่อส่งการแจ้งเตือนแบบพุชและดูการทำงานของมัน