انتقل إلى المحتوى

واجهة برمجة تطبيقات 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
المعلمةالنوعمطلوب/اختياريالوصف
applicationStringمطلوبرمز تطبيق Pushwoosh
authStringمطلوبرمز وصول API من لوحة تحكم Pushwoosh.
notificationsArrayمطلوبمصفوفة JSON لمعلمات الرسالة. انظر التفاصيل في جدول الإشعارات أدناه.

الإشعارات

Anchor link to

المعلمات المستخدمة في مصفوفة notifications:

المعلمةالنوعمطلوب/اختياريالوصف
contentStringمطلوبمحتوى احتياطي للأجهزة التي تعمل بإصدارات iOS أقل من 16.1 والتي لا تدعم Live Activity. على iOS 16.1+ (مع دعم Live Activity)، يتم الحصول على المحتوى من حقل live_activity.
titleStringاختياريعنوان رسالة الإشعار.
live_activityObjectمطلوببيانات Live Activity لإنشاء Live Activity في iOS.
content-stateObjectمطلوبمحتوى إشعار Live Activity.
attributes-typeStringمطلوبنوع السمات المستخدمة في Live Activity.
attributesObjectمطلوبسمات لـ Live Activity.
live_activity_idStringمطلوبمعرف فريد لـ Live Activity، يتم إنشاؤه بواسطة المستخدم.
filter_codeStringاختياريرمز الفلتر (Segment) لاستهداف شرائح جمهور محددة.
devicesArray of stringsاختياريالرموز أو HWIDs لإرسال إشعارات دفع مستهدفة، بحد أقصى 1000. إذا تم تعيينها، سيتم إرسال الرسالة فقط إلى الأجهزة الموجودة في القائمة. ملاحظة: لا يُسمح بـ Application Group لقائمة الأجهزة، ويجب أن تكون رموز دفع iOS بأحرف صغيرة.
usersArray of stringsاختياريإذا تم تعيينها، سيتم تسليم الرسالة فقط إلى معرفات المستخدم (User ID) المحددة (المعينة عبر استدعاء /registerUser). يمكنك تضمين ما يصل إلى 1000 معرف مستخدم في المصفوفة. ملاحظة: إذا تم استخدامها مع معلمة devices، فستكون لمعلمة users الأسبقية. لا يُسمح بـ Application Group لقائمة المستخدمين.

الاستجابة

Anchor link to

200

{
"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
المعلمةالنوعمطلوب/اختياريالوصف
authStringمطلوبرمز وصول API من لوحة تحكم Pushwoosh.
applicationStringمطلوبرمز تطبيق Pushwoosh
notificationsArrayمطلوبمصفوفة JSON لمعلمات الرسالة. انظر التفاصيل في جدول الإشعارات أدناه.

الإشعارات

Anchor link to

المعلمات المستخدمة في مصفوفة notifications:

المعلمةالنوعمطلوب/اختياريالوصف
live_activityObjectمطلوببيانات Live Activity لتحديث Live Activity في iOS.
eventStringمطلوبيحدد نوع الحدث. استخدم "update" لتحديث Live Activity أو "end" لإغلاقه.
content-stateObjectمطلوبكائن يحتوي على أزواج مفتاح-قيمة يستخدم لتمرير البيانات إلى Live Activity لتحديث محتواه.
dismissal-dateIntegerاختياريالوقت (بالثواني) الذي يجب أن ينتهي فيه Live Activity.
live_activity_idStringمطلوبمعرف فريد لـ Live Activity الذي يتم تحديثه.
relevance-scoreIntegerاختيارييخبر نظام iOS أي Live Activity له أولوية أعلى من غيره. يقبل القيم من 1 إلى ما لا نهاية (يوصى بالقيم حتى 100).
stale-dateIntegerاختياريالوقت (بالثواني) الذي يمثل التاريخ الذي يصبح فيه 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.