تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
توفّر إشعارات Pub/Sub طريقة لتلقّي تنبيهات بشأن الأجهزة التي تم تسجيلها حديثًا وتقارير الأجهزة والأوامر الصادرة مؤخرًا.
لإعداد إشعارات Pub/Sub، عليك تفعيل واجهة برمجة التطبيقات Pub/Sub وإنشاء موضوع. لتلقّي الرسائل المنشورة في موضوع معيّن، عليك إنشاء اشتراك في هذا الموضوع. يربط الاشتراك الموضوع بتطبيق مشترك يتلقّى الرسائل المنشورة في الموضوع ويعالجها. بعد إنشاء اشتراك، عليك منح تطبيق Android Device Policy الإذن بالنشر في موضوعك.
إضافة serviceAccount:android-cloud-policy@system.gserviceaccount.com إلى
members
اضبط قيمة role على roles/pubsub.publisher.
5- تحديث المؤسسة لتفعيل الإشعارات
تخطَّ هذه الخطوة إذا كان الإشعار الذي تريد إتاحة استخدامه هو ENTERPRISE_UPGRADE،
الذي يمكن استخدامه دائمًا.
لربط الإشعارات حول مؤسسة بالموضوع الذي أنشأته، استخدِم
enterprises.patch
وحدِّد المَعلمات التالية:
pubsubTopic: اسم موضوع النشر/الاشتراك بالتنسيق
projects/{project}/topics/{topic}
enabledNotificationTypes: أدرِج جميع أنواع الإشعارات التي تريد تلقّيها.
6. استخدام واجهة برمجة تطبيقات Pub/Sub لتلقّي الإشعارات
يمكن أن يستخدم الاشتراك إما آلية الدفع أو السحب لتسليم الرسائل.
تتوفّر الإرشادات والتعليمات حول كيفية تلقّي الإشعارات من خلال هاتين الآليتَين في دليل المشتركين في Pub/Sub.
تنسيق الرسالة
تتخذ الرسائل شكل PubsubMessage.
يحتوي الحقل attributes في الرسالة على سمة تتضمّن المفتاح notificationType والقيمة المضبوطة على نوع الإشعار الذي أدى إلى ظهور الرسالة (مثل ENROLLMENT). يحتوي الحقل data في الرسالة على تمثيل JSON للمورد الذي تم تعديله، والذي تم ترميزه كسلسلة UTF-8. في ما يلي الإشعارات وأنواع الموارد ذات الصلة:
عند ضبط pubsubTopic على Enterprise، سيتم نشر رسالة أولية مع ضبط notificationType على test. يتم إرسال هذه الرسالة للتحقّق من أنّ تطبيق Android Device Policy لديه إذن النشر في الموضوع، ويجب تجاهلها.
مدة الاستجابة المتوقّعة
من المتوقّع أن يتم إرسال أحداث الترقية إلى Enterprise على الفور.
يتم تجميع أحداث الجهاز المحلية التي تحدث بالتتابع السريع وإعداد تقارير عنها في رسالة Pub/Sub واحدة يتم إرسالها إلى أنظمة إدارة الخدمات الجوّالة للمؤسسات (EMM).
نوع الحدث
وقت الاستجابة المتوقّع بين حدث على الجهاز وإشعار EMM المقابل1
الأحداث المرتبطة بالتطبيق أثناء عملية التوفير،
للتطبيقات التي تحدّد حالات تثبيتها مشرف تكنولوجيا المعلومات2
خلال دقيقة واحدة بالإضافة إلى أحداث توفير أخرى ذات صلة
الأحداث ذات الصلة بالتطبيق بعد توفير الجهاز،
بالنسبة إلى التطبيقات التي تحدّد حالة تثبيتها مشرف تكنولوجيا المعلومات
خلال 5 دقائق
الأحداث المرتبطة بالتطبيقات أثناء عملية الإعداد وبعدها، وذلك للتطبيقات التي حدّد الموظف3 حالات تثبيتها
خلال 60 دقيقة
أحداث أخرى للتطبيقات على الجهاز
خلال 60 دقيقة
أهداف مبنية على بذل أقصى مجهود استنادًا إلى ظروف خاضعة للرقابة قد يختلف وقت الاستجابة الفعلي وفقًا لمجموعة متنوعة من العوامل المتعلقة بالجهاز والبيئة. ↩
InstallType من التطبيقات التي يتم فرضها في السياسة: FORCE_INSTALLED وBLOCKED وREQUIRED_FOR_SETUP وPREINSTALLED وKIOSK. ↩
InstallType من التطبيقات المتاحة: AVAILABLE وINSTALL_TYPE_UNSPECIFIED. ↩
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003ePub/Sub notifications alert you about device enrollments, reports, and commands issued through the Android Management API.\u003c/p\u003e\n"],["\u003cp\u003eTo set up, you'll need to enable the Pub/Sub API, create a topic and subscription, and grant Android Device Policy publishing rights.\u003c/p\u003e\n"],["\u003cp\u003eEnterprises can be configured to receive specific notification types like enrollment, status reports, and commands by updating their settings.\u003c/p\u003e\n"],["\u003cp\u003eMessages are delivered via Pub/Sub and contain information about the event, including the notification type and resource details.\u003c/p\u003e\n"],["\u003cp\u003eDevice events are often batched into a single Pub/Sub message, and latency between event and notification can vary but is generally within a predictable timeframe.\u003c/p\u003e\n"]]],["To utilize Pub/Sub notifications for Android Management API, first, enable the Pub/Sub API and create a topic, noting its name. Next, create a subscription for the topic. Grant `android-cloud-policy@system.gserviceaccount.com` Pub/Sub Publisher permission. Update your enterprise via `enterprises.patch` to include the topic name and desired notification types (ENROLLMENT, STATUS_REPORT, COMMAND). Finally, use the Pub/Sub API to retrieve notifications, which contain attributes like `notificationType` and a JSON resource in the `data` field. Existing EMM partners need to register their Cloud project.\n"],null,["# Set up Pub/Sub notifications\n\n| **Note:** Existing EMM partners with [programmatically created ESAs](/android/work/play/emm-api/create-enterprise#create_enterprise_service_accounts_programmatically) need to register their preferred Cloud project with Google before setting up Pub/Sub notifications for Android Management API. For more details, see the [Guide for existing EMM partners](/android/management/existing-emms#set_up_pubsub_notifications).\n\nPub/Sub notifications provide a way for you to receive alerts about newly\nenrolled devices, device reports, and recently issued [commands](/android/management/introduction#commands).\n\nTo set up Pub/Sub notifications, you need to enable the Pub/Sub API and create a\n*topic*. To receive messages published to a topic, create a subscription to that\ntopic. The subscription connects the topic to a subscriber application that\nreceives and processes messages published to the topic. After you create a\nsubscription, you need to grant Android Device Policy permission to publish to\nyour topic.\n\n1. Enable the Pub/Sub API for your project\n------------------------------------------\n\nFor instructions on how to enable the Pub/Sub API, see the\n[console quickstart guide](https://cloud.google.com/pubsub/docs/quickstart-console#before-you-begin). Ensure that you select the **same project** that\nthe [Android Management API is enabled for](/android/management/service-account#enable_the_android_management_api).\n\n2. Create a topic\n-----------------\n\nAfter enabling the API, you need to create a topic that Android Device Policy\ncan publish notifications to. There are two ways to create a topic:\n\na. Manually in the [Google Cloud console](https://cloud.google.com/pubsub/docs/quickstart-console#create_a_topic). \n\nb. Using the Pub/Sub API (see [create topic method](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/create)).\n\nAfter creating a topic, take note of the topic name.\n\n3. Create a subscription\n------------------------\n\nA subscription captures the stream of messages published to a given topic. There\nare two ways to create a subscription:\n\na. Manually in the [Google Cloud console](https://cloud.google.com/pubsub/docs/quickstart-console#add_a_subscription). \n\nb. Using the Pub/Sub API (see [create subscription method](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/create)).\n\n4. Grant Android Device Policy the right to publish to your topic\n-----------------------------------------------------------------\n\nYou need to give android-cloud-policy@system.gserviceaccount.com permission to\npublish to your topic. There are two ways to grant publishing rights:\n\na. Manually in the [Google Cloud console](https://cloud.google.com/pubsub/docs/access_control#console).\n\n- Add android-cloud-policy@system.gserviceaccount.com as a member to your topic.\n- Click **Select a role** \\\u003e **Pub/Sub** \\\u003e **Pub/Sub Publisher**.\n\nb. Using the Pub/Sub API (see [Controlling access through the IAM API](https://cloud.google.com/pubsub/docs/access_control#api))\n\n- Add `serviceAccount:android-cloud-policy@system.gserviceaccount.com` to `members`.\n- Set `role` to `roles/pubsub.publisher`.\n\n5. Update enterprise to support notifications\n---------------------------------------------\n\nSkip this step if the notification you want to support is `ENTERPRISE_UPGRADE`,\nwhich is always supported.\n\nTo connect notifications about an enterprise to the topic you created, call\n[`enterprises.patch`](/android/management/reference/rest/v1/enterprises/patch)\nand specify the following parameters:\n\n- `pubsubTopic`: The name of your pub/sub topic in the form `projects/{project}/topics/{topic}`.\n- `enabledNotificationTypes`: Include all the notification [types](/android/management/reference/rest/v1/enterprises#NotificationType) you want to receive.\n\n6. Use the Pub/Sub API to get notifications\n-------------------------------------------\n\nA subscription can use either the push or pull mechanism for message delivery.\nGuidelines and directions on how to receive notifications through both of these\nmechanisms are available in the [Pub/Sub Subscriber Guide](https://cloud.google.com/pubsub/docs/subscriber).\n\nMessage format\n--------------\n\nMessages take the form of a [PubsubMessage](https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage).\nThe `attributes` field of the message contains an attribute with key\n`notificationType` and value set to the notification type that triggered the\nmessage (e.g. `ENROLLMENT`). The `data` field of the message contains the JSON\nrepresentation of the resource that was updated, encoded as a UTF-8 string. The\nnotifications and their corresponding resource types are as follows:\n\n- `COMMAND` notifications use the resource type [Operation](/android/management/reference/rest/v1/enterprises.devices.operations#resource-operation).\n- `USAGE_LOGS` notifications use the resource type [UsageLogEvent](/android/management/reference/rest/v1/BatchUsageLogEvents#usagelogevent).\n- `ENROLLMENT` and `STATUS_REPORT` notifications use the resource type [Device](/android/management/reference/rest/v1/enterprises.devices#resource-device).\n- `ENTERPRISE_UPGRADE` notifications use the resource type [EnterpriseUpgradeEvent](/android/management/reference/rest/v1/EnterpriseUpgradeEvent).\n\nWhen setting the `pubsubTopic` on an Enterprise, an initial message will be\npublished with `notificationType` set to `test`. This message is sent to verify\nAndroid Device Policy has the publish permission on the topic and should be\nignored.\n| **Note:** When using the Pub/Sub REST API, the `data` field is encoded as a base64 string. To get the resource JSON, first perform base64 decoding on the contents of `data`, then interpret the resulting bytes as a UTF-8 string.\n\nExpected latency\n----------------\n\nEnterprise upgrade events are expected to be sent immediately.\n\nLocal device events that occur in quick succession are batched and reported in a\nsingle Pub/Sub message to EMMs.\n\n| Event type | Expected latency between on-device event and corresponding EMM notification^[1](#fn1)^ |\n|--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|\n| High priority [keyed app states](/android/management/app-feedback) | Immediate, at most one report per minute |\n| Standard priority [keyed app states](/android/management/app-feedback) | Within one minute |\n| Application-related events during provisioning, for apps with install states defined by the IT admin^[2](#fn2)^ | Within one minute on top of other related provisioning events |\n| Application-related events after provisioning, for apps with install states defined by the IT admin. | Within 5 minutes |\n| Application-related events both during and after provisioning, for apps with install states defined by the employee^[3](#fn3)^ | Within 60 minutes |\n| Other on-device app events | Within 60 minutes |\n\n*** ** * ** ***\n\n1. Best effort targets based on controlled circumstances. Actual latency may\n vary according to a variety of device and environmental factors. [↩](#fnref1)\n\n2. [`InstallType`](/android/management/reference/rest/v1/enterprises.policies#installtype) of apps enforced in the policy: `FORCE_INSTALLED`,\n `BLOCKED`, `REQUIRED_FOR_SETUP`, `PREINSTALLED` and `KIOSK`. [↩](#fnref2)\n\n3. [`InstallType`](/android/management/reference/rest/v1/enterprises.policies#installtype) of available apps: `AVAILABLE`,\n `INSTALL_TYPE_UNSPECIFIED`. [↩](#fnref3)"]]