واجهة برمجة تطبيقات iOS Live Activities
وثائق Apple:
startLiveActivity
Anchor link toاستخدم هذه الطريقة لإنشاء iOS Live Activities.
POST https://api.pushwoosh.com/json/1.3/startLiveActivity
تسمح بإنشاء iOS Live Activities.
نص الطلب
Anchor link to| المعلمة | النوع | مطلوب/اختياري | الوصف |
|---|---|---|---|
| application | String | مطلوب | رمز تطبيق Pushwoosh |
| auth | String | مطلوب | رمز وصول API من لوحة تحكم Pushwoosh. |
| notifications | Array | مطلوب | مصفوفة JSON لمعلمات الرسالة. انظر التفاصيل في جدول الإشعارات أدناه. |
الإشعارات
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 | مطلوب | نوع السمات المستخدمة في Live Activity. |
| attributes | Object | مطلوب | سمات لـ Live Activity. |
| live_activity_id | String | مطلوب | معرف فريد لـ Live Activity، يتم إنشاؤه بواسطة المستخدم. |
| filter_code | String | اختياري | رمز الفلتر (Segment) لاستهداف شرائح جمهور محددة. |
| devices | Array of strings | اختياري | الرموز أو HWIDs لإرسال إشعارات دفع مستهدفة، بحد أقصى 1000. إذا تم تعيينها، سيتم إرسال الرسالة فقط إلى الأجهزة الموجودة في القائمة. ملاحظة: لا يُسمح بـ Application Group لقائمة الأجهزة، ويجب أن تكون رموز دفع iOS بأحرف صغيرة. |
| users | Array of strings | اختياري | إذا تم تعيينها، سيتم تسليم الرسالة فقط إلى معرفات المستخدم (User ID) المحددة (المعينة عبر استدعاء /registerUser). يمكنك تضمين ما يصل إلى 1000 معرف مستخدم في المصفوفة. ملاحظة: إذا تم استخدامها مع معلمة devices، فستكون لمعلمة users الأسبقية. لا يُسمح بـ Application Group لقائمة المستخدمين. |
الاستجابة
Anchor link to200
{ "status_code": 200, "status_message": "OK", "response": { "Messages": [ "C3F8-C3863ED4-334AD4F1" ] }}مثال على الطلب
Anchor link to{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "live_activity": { // required. Live Activity data to create Live Activity in iOS "content-state": { "emoji": ":wink:" }, "attributes-type": "LiveActivityAttributes", "attributes": { "name": "Apple" } }, "live_activity_id": "unique UUID", // optional. Unique identifier of the Live Activity. "filter_code": "FILTER_NAME", // optional. Specify filter. "devices": [ // optional. Specify tokens or hwids to send targeted push "hwid_XXXX" // notifications. Not more than 1000 tokens/hwids in ], // an array. If set, the message will only be sent to // the devices on the list. Application Group for // devices list is not allowed. // iOS push tokens can only be lower case. "users": [ // optional. If set, message will only be delivered to the specified "user_XXXX" // user ID's (set via /registerUser call). If specified ] // together with devices parameter, the latter will be // ignored. Not more than 1000 user ID's in an array. // Application Group for users list is not allowed. }] }}ملاحظة:
اقرأ هذا المقال لمعرفة المزيد حول العمل مع Live Activities باستخدام Pushwoosh iOS SDK.
updateLiveActivity
Anchor link toاستخدم هذه الطريقة لإدارة iOS Live Activities.
POST https://api.pushwoosh.com/json/1.3/updateLiveActivity
تسمح بإنشاء وإدارة iOS Live Activities.
نص الطلب
Anchor link to| المعلمة | النوع | مطلوب/اختياري | الوصف |
|---|---|---|---|
| auth | String | مطلوب | رمز وصول API من لوحة تحكم Pushwoosh. |
| application | String | مطلوب | رمز تطبيق Pushwoosh |
| notifications | Array | مطلوب | مصفوفة JSON لمعلمات الرسالة. انظر التفاصيل في جدول الإشعارات أدناه. |
الإشعارات
Anchor link toالمعلمات المستخدمة في مصفوفة notifications:
| المعلمة | النوع | مطلوب/اختياري | الوصف |
|---|---|---|---|
| live_activity | Object | مطلوب | بيانات Live Activity لتحديث Live Activity في iOS. |
| event | String | مطلوب | يحدد نوع الحدث. استخدم "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" ] }}مثال على الطلب
Anchor link to{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "live_activity": { // required. Live Activity data to update Live Activity in iOS "event": "update", // required. Use "update" to update Live Activity or // "end" to close Live Activity "content-state": { // required. Object with key-value pairs used to pass data "courierName": "NUMBER: 15", // to Live Activity for updating its content "deliveryStatus": "Done" }, "dismissal-date": 12345678, // optional. Time of ending Live Activity in seconds "relevance-score": 50, // optional. Priority for the Live Activity (1 to 100 recommended) "stale-date": 23456789 // optional. Time (in seconds) when Live Activity becomes stale }, "live_activity_id": "unique UUID" // optional. Unique identifier of the Live Activity. }] }}اقرأ هذا المقال لمعرفة المزيد حول العمل مع Live Activities باستخدام Pushwoosh iOS SDK.