API สำหรับ iOS Live Activities
เอกสารของ Apple:
startLiveActivity
Anchor link toใช้เมธอดนี้เพื่อสร้าง iOS Live Activities
POST https://api.pushwoosh.com/json/1.3/startLiveActivity
อนุญาตให้สร้าง iOS Live Activities
Request body
Anchor link to| พารามิเตอร์ | ประเภท | จำเป็น/ไม่จำเป็น | คำอธิบาย |
|---|---|---|---|
| application | String | จำเป็น | รหัสแอปพลิเคชัน Pushwoosh |
| auth | String | จำเป็น | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
| notifications | Array | จำเป็น | อาร์เรย์ JSON ของพารามิเตอร์ข้อความ ดูรายละเอียดในตาราง Notifications ด้านล่าง |
Notifications
Anchor link toพารามิเตอร์ที่ใช้ในอาร์เรย์ notifications:
| พารามิเตอร์ | ประเภท | จำเป็น/ไม่จำเป็น | คำอธิบาย |
|---|---|---|---|
| content | String | จำเป็น | เนื้อหาสำรองสำหรับอุปกรณ์ที่ใช้ iOS เวอร์ชันต่ำกว่า 16.1 ที่ไม่รองรับ Live Activity สำหรับ iOS 16.1+ (ที่รองรับ Live Activity) เนื้อหาจะมาจากฟิลด์ live_activity |
| title | String | ไม่จำเป็น | ชื่อเรื่องของข้อความแจ้งเตือน |
| live_activity | Object | จำเป็น | ข้อมูล Live Activity เพื่อสร้าง Live Activity ใน iOS |
| content-state | Object | จำเป็น | เนื้อหาสำหรับการแจ้งเตือน Live Activity |
| attributes-type | String | จำเป็น | ประเภทของ attributes ที่ใช้ใน Live Activity |
| attributes | Object | จำเป็น | Attributes สำหรับ Live Activity |
| live_activity_id | String | จำเป็น | ID ที่ไม่ซ้ำกันสำหรับ Live Activity ซึ่งสร้างโดยผู้ใช้ |
Response
Anchor link to200
{ "status_code": 200, "status_message": "OK", "response": { "Messages": [ "C3F8-C3863ED4-334AD4F1" ] }}ตัวอย่าง Request
Anchor link to{ "request": { "application": "XXXXX-XXXXX", // จำเป็น รหัสแอปพลิเคชัน Pushwoosh "auth": "yxoPUlwqm…………pIyEX4H", // จำเป็น โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel "notifications": [{ "live_activity": { // จำเป็น ข้อมูล Live Activity เพื่อสร้าง Live Activity ใน iOS "content-state": { "emoji": ":wink:" }, "attributes-type": "LiveActivityAttributes", "attributes": { "name": "Apple" } }, "live_activity_id": "unique UUID" // ไม่จำเป็น ตัวระบุที่ไม่ซ้ำกันของ Live Activity }] }}หมายเหตุ:
อ่านบทความนี้เพื่อเรียนรู้เพิ่มเติมเกี่ยวกับการทำงานกับ Live Activities โดยใช้ Pushwoosh iOS SDK
updateLiveActivity
Anchor link toใช้เมธอดนี้เพื่อจัดการ iOS Live Activities
POST https://api.pushwoosh.com/json/1.3/updateLiveActivity
อนุญาตให้สร้างและจัดการ iOS Live Activities
Request body
Anchor link to| พารามิเตอร์ | ประเภท | จำเป็น/ไม่จำเป็น | คำอธิบาย |
|---|---|---|---|
| auth | String | จำเป็น | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
| application | String | จำเป็น | รหัสแอปพลิเคชัน Pushwoosh |
| notifications | Array | จำเป็น | อาร์เรย์ JSON ของพารามิเตอร์ข้อความ ดูรายละเอียดในตาราง Notifications ด้านล่าง |
Notifications
Anchor link toพารามิเตอร์ที่ใช้ในอาร์เรย์ notifications:
| พารามิเตอร์ | ประเภท | จำเป็น/ไม่จำเป็น | คำอธิบาย |
|---|---|---|---|
| live_activity | Object | จำเป็น | ข้อมูล Live Activity เพื่ออัปเดต Live Activity ใน iOS |
| event | String | จำเป็น | ระบุประเภทของ event ใช้ "update" เพื่ออัปเดต Live Activity หรือ "end" เพื่อปิด |
| content-state | Object | จำเป็น | อ็อบเจกต์ที่มีคู่คีย์-ค่าที่ใช้ในการส่งข้อมูลไปยัง Live Activity เพื่ออัปเดตเนื้อหา |
| dismissal-date | Integer | ไม่จำเป็น | เวลา (เป็นวินาที) ที่ Live Activity ควรจะสิ้นสุด |
| live_activity_id | String | จำเป็น | ตัวระบุที่ไม่ซ้ำกันสำหรับ Live Activity ที่กำลังอัปเดต |
| relevance-score | Integer | ไม่จำเป็น | บอกระบบ iOS ว่า Live Activity ใดมีความสำคัญสูงกว่ารายการอื่น ๆ รับค่าตั้งแต่ 1 ถึงอนันต์ (แนะนำให้ใช้ค่าไม่เกิน 100) |
| stale-date | Integer | ไม่จำเป็น | เวลา (เป็นวินาที) ที่แสดงถึงวันที่ Live Activity กลายเป็นข้อมูลเก่าหรือไม่เป็นปัจจุบัน |
{ "status_code": 200, "status_message": "OK", "response": { "Messages": [ "C3F8-C3863ED4-334AD4F1" ] }}ตัวอย่าง Request
Anchor link to{ "request": { "application": "XXXXX-XXXXX", // จำเป็น รหัสแอปพลิเคชัน Pushwoosh "auth": "yxoPUlwqm…………pIyEX4H", // จำเป็น โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel "notifications": [{ "live_activity": { // จำเป็น ข้อมูล Live Activity เพื่ออัปเดต Live Activity ใน iOS "event": "update", // จำเป็น ใช้ "update" เพื่ออัปเดต Live Activity หรือ // "end" เพื่อปิด Live Activity "content-state": { // จำเป็น อ็อบเจกต์ที่มีคู่คีย์-ค่าที่ใช้ในการส่งข้อมูล "courierName": "NUMBER: 15", // ไปยัง Live Activity เพื่ออัปเดตเนื้อหา "deliveryStatus": "Done" }, "dismissal-date": 12345678, // ไม่จำเป็น เวลาสิ้นสุด Live Activity เป็นวินาที "relevance-score": 50, // ไม่จำเป็น ลำดับความสำคัญสำหรับ Live Activity (แนะนำ 1 ถึง 100) "stale-date": 23456789 // ไม่จำเป็น เวลา (เป็นวินาที) ที่ Live Activity จะกลายเป็นข้อมูลเก่า }, "live_activity_id": "unique UUID" // ไม่จำเป็น ตัวระบุที่ไม่ซ้ำกันของ Live Activity }] }}อ่านบทความนี้เพื่อเรียนรู้เพิ่มเติมเกี่ยวกับการทำงานกับ Live Activities โดยใช้ Pushwoosh iOS SDK