重要提示:我们不再接受 Play EMM API 的新注册。
了解详情。
设置 EMM 通知
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Google Play 会根据影响企业的各种事件生成通知(称为 EMM 通知)。例如,当应用获得批准时,系统会发送 ProductApprovalEvent
通知。
EMM 通知与特定的企业服务账号 (ESA) 相关联。作为 EMM,您可以将控制台设置为根据您收到的通知向企业 IT 管理员显示提醒或消息。
EMM 通知使用 Google Cloud Pub/Sub 发送。如需详细了解如何设置 Pub/Sub 通知,请参阅订阅者概览和拉取订阅者指南。
如需确认您已成功将系统设置为接收来自 Google Play 的 EMM 通知,并检索您需要将订阅关联到的 Cloud Pub/Sub 主题的名称,请调用 Enterprises.sendTestPushNotification
。
发送测试通知可验证您的 EMM 与企业的 Google Cloud Pub/Sub 服务的集成情况。如果 EMM 通知配置正确,API 会返回以下内容:
{
topic_name: "/projects/project-name/topics/play-work-012345",
message_id: "128976912439"
}
拉取通知
Google Cloud Pub/Sub 支持两种不同的通知机制:拉取和推送。不过,我们建议仅使用拉取通知。拉取方法无需任何外部服务器设置,并且适用于程序化创建和手动创建的 ESA。拉取通知的另一个优势是,客户几乎无需进行额外的配置或维护。您可以使用 Enterprises.pullNotificationSet
和 Enterprises.acknowledgeNotificationSet
通过长时间运行的出站连接接收和确认 EMM 通知。
调用 Enterprises.pullNotificationSet
时,我们建议将 requestMode
保留为其默认值 (waitForNotifications
)。这会导致请求等到出现一个或多个通知后,再返回响应。如果一段时间后没有任何通知,请求会返回一个空通知列表,然后您可以再次尝试该请求。
收到通知后,请调用 Enterprises.acknowledgeNotificationSet
,以确保下次调用 Enterprises.pullNotificationSet
时不会返回相同的通知。
您还可以选择在调用 Enterprises.pullNotificationSet
时将 requestMode
设置为 returnImmediately
。您会立即收到对该请求的回复,其中包含所有待处理通知,如果没有通知,则会显示一个空列表。在初始测试通知实现时,此 requestMode
选项可能很有用。
EMM 通知示例
以下是一些事件及其生成的通知类型示例:
注意:以下通知类型已废弃:ProductApprovalEvent
、AppUpdateEvent
、NewPermissionsEvent
、AppRestrictionsSchemaChangeEvent
、ProductAvailabilityChangeEvent
和 NewDeviceEvent
。对于 AppUpdateEvent
,您必须按照我们的建议使用 高优先级更新模式 。
说明 | 通知 |
通过
Google Play EMM API 请求测试通知。您需要发送测试通知,以确认您的系统可以接收 Google Play 发布的通知,并了解与 Google Play 关联的所有通知所使用的主题名称。 | TestPushNotification |
新配置的设备可以由 Google Play EMM API 进行管理。现在,您可以调用需要设备 deviceId 的 API(例如 Installs)以及返回 Devices 资源的 API。只有在受管理设备上预配第一个账号后,系统才会发送此通知。已弃用
| NewDeviceEvent |
管理员在 Google Play 企业版控制台中将应用标记为已批准或未批准。已弃用
| ProductApprovalEvent
|
设备上的待处理安装超时。例如,系统接受了推送安装请求,但设备几天都无法访问,因此无法确认安装。系统会发送安装超时通知。 | InstallFailureEvent
|
发布应用的新版本。更新适用于一个或多个设备,但不一定适用于所有设备。已弃用
| AppUpdateEvent
|
应用更新需要获得管理员批准的新权限,才能进行更新或新安装。当应用接受的权限集与应用请求的权限集不同时,系统会发送此通知。已弃用
| NewPermissionsEvent |
发布了应用的新版本,其中包含新的或经过修改的受管理的配置架构。当开发者上传新的 APK 时,Google Play 会将清单中的架构与应用的旧版本中的架构进行比较。如果架构发生了变化,Google Play 会通知已批准该应用的企业。已废弃
|
AppRestrictionsSchemaChangeEvent |
可用的应用变为不可用,或者不可用的应用重新添加到 Google Play。如果开发者取消发布应用或应用从 Google Play 下架,应用的可用性就会发生变化。如果已下架的应用重新添加到 Google Play,其上架情况也会随之发生变化。已弃用
|
ProductAvailabilityChangeEvent |
与企业升级相关的通知。企业升级是指将 Google Play 企业版账号集升级为 Google 企业版域名的过程。 |
EnterpriseUpgradeEvent |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eGoogle Play uses EMM notifications, sent via Google Cloud Pub/Sub, to inform enterprises of events like app approvals or new device provisioning.\u003c/p\u003e\n"],["\u003cp\u003eEMMs can configure their systems to display alerts to IT administrators based on these notifications.\u003c/p\u003e\n"],["\u003cp\u003ePull notifications are the recommended method for receiving EMM notifications, offering advantages in setup and maintenance.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eEnterprises.pullNotificationSet\u003c/code\u003e and \u003ccode\u003eEnterprises.acknowledgeNotificationSet\u003c/code\u003e are used to manage the retrieval and acknowledgment of EMM notifications.\u003c/p\u003e\n"],["\u003cp\u003eVarious notification types correspond to specific events, such as app updates, install failures, and new device provisioning, though some have been deprecated.\u003c/p\u003e\n"]]],[],null,["# Set up EMM notifications\n\nGoogle Play generates notifications, referred to as **EMM notifications** , in\nresponse to various events that affect an enterprise. For example, when an app\nis approved, the system sends a `ProductApprovalEvent` notification.\n\nEMM notifications are associated with a specific [enterprise service account\n(ESA)](/android/work/overview#service_accounts). As an EMM, you can set up your\nconsole to display alerts or messages to enterprise IT administrators based on\nthe notifications that you receive.\n\nEMM notifications are sent using [Google Cloud\nPub/Sub](//cloud.google.com/pubsub/overview). For detailed information on how to\nset up a Pub/Sub notifications, see the [Subscriber\nOverview](//cloud.google.com/pubsub/docs/subscriber) and [Pull Subscriber\nGuide](//cloud.google.com/pubsub/docs/pull).\n\nTo confirm that you have successfully set up your system to receive EMM\nnotifications from Google Play and to retrieve the name of the Cloud Pub/Sub\ntopic that you need to connect your subscription to, call\n[`Enterprises.sendTestPushNotification`](/android/work/play/emm-api/v1/enterprises/sendTestPushNotification).\n\nSending a test notification validates your EMM integration with the Google Cloud\nPub/Sub service for the enterprise. If EMM notifications are properly\nconfigured, the API returns the following: \n\n {\n topic_name: \"/projects/project-name/topics/play-work-012345\",\n message_id: \"128976912439\"\n }\n\nPull notifications\n------------------\n\nGoogle Cloud Pub/Sub supports two different notification mechanisms: pull and\npush. However, only pull notifications are recommended. The pull approach\ndoesn't require any external server setup, and works with both programmatically\nand manually created ESAs. Another advantage of pull notifications is that they\nrequire little to no additional configuration or maintenance by your customers.\nuse\n[`Enterprises.pullNotificationSet`](/android/work/play/emm-api/v1/enterprises/pullNotificationSet)\nand\n[`Enterprises.acknowledgeNotificationSet`](/android/work/play/emm-api/v1/enterprises/acknowledgeNotificationSet)\nto receive and acknowledge EMM notifications over long-running outgoing\nconnections.\n\nWhen calling\n[`Enterprises.pullNotificationSet`](/android/work/play/emm-api/v1/enterprises/pullNotificationSet),\nwe recommend leaving the `requestMode` to its default value\n(`waitForNotifications`). This causes the request to wait until one or more\nnotifications are present before returning a response. If no notifications are\npresent after some time, the request returns an empty notification list, after\nwhich you can try the request again.\n\nAfter you receive notifications, call\n[`Enterprises.acknowledgeNotificationSet`](/android/work/play/emm-api/v1/enterprises/acknowledgeNotificationSet)\nto ensure that the same notifications aren't returned the next time you call\n`Enterprises.pullNotificationSet`.\n\nYou also have the option of setting `requestMode` to `returnImmediately` when\ncalling `Enterprises.pullNotificationSet`. You'll receive a response to the\nrequest immediately, containing any pending notifications or an empty list if no\nnotifications are present. This `requestMode` option may be useful when you\ninitially test your notifications implementation.\n\nExamples of EMM notifications\n-----------------------------\n\nHere are some examples of events and the notification types that they generate:\n\n**Note:** The following notification types have been deprecated:\n`ProductApprovalEvent`, `AppUpdateEvent`, `NewPermissionsEvent`,\n`AppRestrictionsSchemaChangeEvent`, `ProductAvailabilityChangeEvent`, and\n`NewDeviceEvent`. For `AppUpdateEvent`, you must use\n[high-priority update mode](/android/work/play/emm-api/update) as\nper our recommendations.\n\n| Description | Notification |\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|\n| A test notification is requested via the [Google Play EMM API](/android/work/play/emm-api/v1/enterprises/sendTestPushNotification). You need to send a test notification to confirm that your system can receive the notifications that Google Play publishes, and to learn the topic name used for all notifications associated with Google Play. | `TestPushNotification` |\n| A newly provisioned device is ready to be managed by the [Google Play EMM API](/android/work/play/emm-api/v1). You can now call APIs that require the device's `deviceId` ([Installs](/android/work/play/emm-api/v1/installs), for example) and APIs that return a [Devices](/android/work/play/emm-api/v1/devices) resource. This notification is only sent after the first account is provisioned on a managed device. **DEPRECATED** | `NewDeviceEvent` |\n| An administrator marks an application as approved or unapproved in the managed Google Play console. **DEPRECATED** | `ProductApprovalEvent` |\n| A pending installation to a device times out. For example, a push install request is accepted, but the device is not reachable for several days, so the install cannot be confirmed. The system sends an install timeout notification. | `InstallFailureEvent` |\n| A new version of an app is published. The update is available to one or more, but not necessarily all, devices. **DEPRECATED** | `AppUpdateEvent` |\n| An app update requires a new permission to be approved by the admin, so that an update or a new install can occur. This notification is sent when the application's accepted permission set differs from the application's requested permissions set. **DEPRECATED** | `NewPermissionsEvent` |\n| A new version of an app is published that includes a new or modified [managed configurations schema](//developer.android.com/work/managed-configurations.html# define-configuration). When a developer uploads a new APK, Google Play compares the schema in the manifest to the schema in the previous version of the app. If the schema has changed, it notifies enterprises that have approved the app. **DEPRECATED** | `AppRestrictionsSchemaChangeEvent` |\n| An available app becomes unavailable, or an unavailable app is re-added to Google Play. The availability of the app changes if a developer unpublishes it, or it is removed from Google Play. The availability also changes if an unavailable app is re-added to Google Play. **DEPRECATED** | `ProductAvailabilityChangeEvent` |\n| A notification related to an enterprise upgrade. An enterprise upgrade is a process that upgrades a managed Google Play Accounts enterprise to a managed Google Domain. | `EnterpriseUpgradeEvent` |"]]