เริ่มต้นใช้งาน iOS SDK อย่างรวดเร็ว
เริ่มต้นใช้งาน Pushwoosh iOS SDK โดยใช้ตัวอย่างที่ง่ายและรวดเร็วนี้
ข้อกำหนดเบื้องต้น
Anchor link toในการผสาน Pushwoosh iOS SDK เข้ากับแอปของคุณ คุณจะต้องมีสิ่งต่อไปนี้:
ดาวน์โหลดโปรเจกต์ตัวอย่าง
Anchor link toโคลนโปรเจกต์ตัวอย่างจาก GitHub:
git clone https://github.com/Pushwoosh/pushwoosh-ios-sample.gitกำหนดค่าโปรเจกต์
Anchor link to-
เปิดโปรเจกต์ใน Xcode
-
เพิ่ม
https://github.com/Pushwoosh/Pushwoosh-XCFrameworkเป็น Swift Package Dependency -
ตั้งค่า bundle identifier สำหรับ target หลัก (PushwooshSampleApp) ให้ตรงกับโปรเจกต์ Pushwoosh ของคุณ (เช่น
com.pushwoosh.PushwooshSampleApp) -
ใช้ bundle identifier เดียวกันสำหรับ target NotificationService โดยต่อท้ายด้วย
.NotificationService(เช่นcom.pushwoosh.PushwooshSampleApp.NotificationService) -
ใน
Info.plistให้ตั้งค่า:- คีย์
Pushwoosh_APPIDเป็น Pushwoosh Application Code - คีย์
Pushwoosh_API_TOKENเป็น Pushwoosh Device API Token
- คีย์
สำคัญ: ตรวจสอบให้แน่ใจว่าได้ให้สิทธิ์ token ในการเข้าถึงแอปที่ถูกต้องใน Pushwoosh Control Panel ของคุณ เรียนรู้เพิ่มเติม
รันโปรเจกต์
Anchor link to- บิวด์และรันโปรเจกต์
- แอปจะมีสองแท็บ: “Actions” และ “Settings” ไปที่แท็บ Settings
- แตะปุ่ม Register for Pushes
- ให้สิทธิ์สำหรับการแจ้งเตือนแบบพุช อุปกรณ์จะถูกลงทะเบียนกับ Pushwoosh
คุณควรจะเห็นรายการบันทึก (log) ลักษณะนี้:
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 แล้ว
ส่งการแจ้งเตือนแบบพุช
Anchor link toกลับไปที่ Pushwoosh Control Panel และ ส่งการแจ้งเตือนแบบพุช ไปยังอุปกรณ์ที่ลงทะเบียนของคุณ
ขั้นตอนถัดไป
Anchor link toหากต้องการเรียนรู้เพิ่มเติม โปรดดูที่ คู่มือการผสานรวมเบื้องต้น