ข้ามไปยังเนื้อหา

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

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

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

Anchor link to

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

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

Anchor link to

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

Terminal window
git clone https://github.com/Pushwoosh/pushwoosh-ios-sample.git

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

Anchor link to
  1. เปิดโปรเจกต์ใน Xcode

  2. เพิ่ม https://github.com/Pushwoosh/Pushwoosh-XCFramework เป็น Swift Package Dependency

  3. ตั้งค่า bundle identifier สำหรับ target หลัก (PushwooshSampleApp) ให้ตรงกับโปรเจกต์ Pushwoosh ของคุณ (เช่น com.pushwoosh.PushwooshSampleApp)

  4. ใช้ bundle identifier เดียวกันสำหรับ target NotificationService โดยต่อท้ายด้วย .NotificationService (เช่น com.pushwoosh.PushwooshSampleApp.NotificationService)

  5. ใน Info.plist ให้ตั้งค่า:

    • คีย์ Pushwoosh_APPID เป็น Pushwoosh Application Code
    • คีย์ Pushwoosh_API_TOKEN เป็น Pushwoosh Device API Token

สำคัญ: ตรวจสอบให้แน่ใจว่าได้ให้สิทธิ์ token ในการเข้าถึงแอปที่ถูกต้องใน Pushwoosh Control Panel ของคุณ เรียนรู้เพิ่มเติม

เรียกใช้โปรเจกต์

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

คุณควรเห็นรายการบันทึกดังนี้:

Terminal window
Pushwoosh: Initializing application runtime
[PW] BUNDLE ID: __YOUR_BUNDLE_ID__
[PW] APP CODE: __YOUR_APP_CODE__
[PW] PUSHWOOSH SDK VERSION: 6.7.13
[PW] HWID: __YOUR_HWID__
[PW] PUSH TOKEN: (null)
[PW] [I] -[PWNotificationManagerCompatiOS10] NotificationCenter authorization granted: 1
[PW] [I] -[PWPushNotificationsManagerCommon] Registered for push notifications: __YOUR_PUSH_TOKEN__

อุปกรณ์ของคุณลงทะเบียนกับ Pushwoosh แล้ว

ส่งการแจ้งเตือนแบบ push

Anchor link to

กลับไปที่ Pushwoosh Control Panel และ ส่งการแจ้งเตือนแบบ push ไปยังอุปกรณ์ที่ลงทะเบียนของคุณ

ขั้นตอนต่อไป

Anchor link to

หากต้องการเรียนรู้เพิ่มเติม โปรดดู คู่มือการรวมพื้นฐาน