A partir del 27 de marzo de 2025, te recomendamos que uses android-latest-release
en lugar de aosp-main
para compilar y contribuir a AOSP. Para obtener más información, consulta Cambios en AOSP.
Permisos de notificaciones para notificaciones de aceptación
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Las notificaciones en Android 13 usan un modelo de aceptación, que es un cambio con respecto a las versiones anteriores de Android, que usan un modelo de rechazo. En Android 13, todas las apps deben pedir permiso a los usuarios antes de enviar mensajes de notificación. Este modelo ayuda a reducir las interrupciones de las notificaciones, minimiza la sobrecarga de información y ayuda a los usuarios a controlar qué notificaciones aparecen en función de lo que es importante para ellos. Para admitir el modelo de aceptación, los OEMs deben implementar cambios en los sistemas de permisos de tiempo de ejecución y notificaciones.
En esta página, se describe lo que los OEMs deben implementar para admitir este cambio y cómo validar la implementación.
Implementa cambios en las notificaciones de aceptación
A partir de Android 13, las apps deben declarar su intención de enviar notificaciones solicitando el permiso de tiempo de ejecución android.permission.POST_NOTIFICATION
del sistema antes de poder enviarlas.
En Android 13 y versiones posteriores, el parámetro de configuración que determina si una app puede enviar notificaciones al usuario se almacena en el sistema de permisos.
Antes de Android 13, este parámetro de configuración se almacenaba en el sistema de notificaciones. Por lo tanto, los OEMs deben migrar los datos de notificaciones existentes sobre si una app puede enviar notificaciones del sistema de notificaciones al sistema de permisos de tiempo de ejecución. Los OEMs también deben mantener las APIs existentes en el sistema de notificaciones que muestran esos datos a los desarrolladores de apps.
Los cambios en los sistemas de notificaciones y permisos se basan en el modelo de aceptación del comportamiento de las notificaciones del usuario y se describen en la sección Lineamientos para la implementación.
Comportamiento de las notificaciones del usuario en un modelo de solicitud de aceptación
En la siguiente tabla, se ilustra el comportamiento de las notificaciones de varias versiones de la app en un dispositivo que ejecuta Android 13:
Dispositivo con Android 13 |
Apps orientadas a Android 13 o versiones posteriores |
Apps orientadas a versiones anteriores a Android 13 |
Nueva instalación
|
Las notificaciones se bloquean hasta que la app lo solicite.
Las apps controlan cuándo solicitar permisos.
|
Las notificaciones se bloquean hasta que el SO lo solicite.
Se solicita el permiso en la primera ejecución de la app.
|
App existente (actualización)
|
Las notificaciones se permiten hasta que la app lo solicite.
Se otorga un permiso temporal hasta que la app lo solicite en la primera ejecución de calificación.
|
Las notificaciones se permiten hasta que el SO lo solicite.
El permiso temporal se otorga hasta la primera ejecución de la app.
|
Lineamientos para la implementación
Para la implementación de referencia, consulta el servicio de notificaciones, el servicio de permisos y el servicio de políticas. Para implementar excepciones para los controladores de permisos predeterminados, consulta Permisos de tiempo de ejecución.
Durante la implementación, usa los siguientes lineamientos sobre el comportamiento de las notificaciones del usuario para las apps orientadas a SDKs de Android 13 o versiones anteriores:
- Las apps recién instaladas en un dispositivo Android 13 no deben enviar notificaciones sin que el usuario apruebe un mensaje de permiso.
- Si la app se orienta a versiones de Android 13 y posteriores, las notificaciones deben bloquearse hasta que la app lo solicite, ya que esta controla cuándo y si se debe solicitar el permiso del usuario.
- Si la app está orientada a versiones anteriores a Android 13, las notificaciones deben bloquearse hasta que el SO lo solicite. El SO debe mostrar el mensaje de permiso en la primera ejecución de la app.
Cualquier app que haya existido en el dispositivo antes de una actualización a Android 13, o cualquier app que se haya restablecido a través de la copia de seguridad y el restablecimiento, debe poder enviar notificaciones hasta la primera vez que el usuario inicie una actividad desde esa app.
En el caso de las apps que se orientan al SDK de las versiones de Android 13 y versiones posteriores, si el usuario no personalizó previamente la configuración de notificaciones de esta app en el nivel de la app o de NotificationChannel
, revoca el otorgamiento de permisos temporal. Luego, las apps deben solicitarle permiso al usuario para poder seguir enviando notificaciones.
Si una app actualizada para Android 13 no tiene actualmente el permiso de notificación a través del otorgamiento de actualización temporal y el usuario la inició al menos una vez, la app debe mostrar un mensaje de permiso de notificación antes de que se le permita ejecutar más servicios en primer plano.
En el caso de las apps que tienen un SDK de destino de versiones anteriores a Android 13, intercepta el primer inicio de actividad después de que la app haya creado al menos un NotificationChannel
para mostrar un mensaje de permiso en el que se le pregunte al usuario si quiere recibir notificaciones de la app.
Si un usuario personalizó anteriormente la configuración de notificaciones a nivel de la app o de NotificationChannel
para una app en el dispositivo que se actualiza o en una copia de seguridad que se restablece en el dispositivo, la configuración a nivel de la app se debe migrar al sistema de permisos con la marca FLAG_PERMISSION_USER_SET
. No se debe mostrar ninguna otra solicitud de permiso de notificación al usuario, a menos que la app lo solicite de forma específica.
La copia de seguridad y el restablecimiento deben ser retrocompatibles y compatibles con versiones posteriores entre un dispositivo con Android 13 y un dispositivo con una versión anterior del SO. Los datos de la copia de seguridad generados desde un dispositivo Android 13 se deben restablecer en una versión anterior del SO, y los datos de la copia de seguridad de una versión anterior del SO se deben restablecer en un dispositivo Android 13.
Las notificaciones multimedia asociadas con la reproducción multimedia en curso deben estar exentas del permiso de notificación.
Valida los cambios en los sistemas de notificaciones y permisos
Para validar la implementación, ejecuta las siguientes pruebas:
El contenido y las muestras de código que aparecen en esta página están sujetas a las licencias que se describen en la Licencia de Contenido. Java y OpenJDK son marcas registradas de Oracle o sus afiliados.
Última actualización: 2025-07-27 (UTC)
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-07-27 (UTC)"],[],[],null,["# Notification permission for opt-in notifications\n\nNotifications in Android 13 use an opt-in model, which\nis a change from previous Android versions, which use an opt-out model. In\nAndroid 13, all apps must ask users for permission before\nsending notification prompts. This model helps reduce notification\ninterruptions, minimizes information overload, and helps users control what\nnotifications appear based on what's important to them. To support the\nopt-in model, OEMs must implement changes in the notification and runtime\npermission systems.\n\nThis page describes what OEMs must implement to support this change and how\nto validate the implementation.\n\nImplement changes for opt-in notifications\n------------------------------------------\n\nStarting with Android 13, apps must declare their\nintent to send notifications by requesting the\n[`android.permission.POST_NOTIFICATION`](https://developer.android.com/about/versions/13/changes/notification-permission)\nruntime permission from the system before they can send notifications.\n\nIn Android 13 and higher, the setting that determines\nif an app can send notifications to the user is stored in the permission system.\nPrior to Android 13, this setting was stored in the\nnotification system. Hence, OEMs must migrate the existing notification data\nabout whether an app is allowed to send notifications, from the notification\nsystem into the runtime permission system. OEMs must also maintain existing APIs\nin the notification system that surface that data to app developers.\n\nChanges to the notification and permission systems are based on the\n[opt-in model of user notification behavior](#behavior-optin) and are\ndescribed in the [Guidelines for implementation](#guidelines-impl) section.\n\n### Behavior of user notifications in an opt-in model\n\nThe following table illustrates the notification behavior for various app\nversions on a device running Android 13:\n\n| Device on Android 13 | Apps targeting Android 13 or higher | Apps targeting versions lower than Android 13 |\n|------------------------|--------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|\n| New install | Notifications are blocked until prompted by the app. Apps control when to ask for permission. | Notifications are blocked until prompted by the OS. Permission is asked on the first run of the app. |\n| Existing app (upgrade) | Notifications are allowed until prompted by the app. Temporary permission is granted until the app asks on the first qualifying run. | Notifications are allowed until prompted by the OS. Temporary permission is granted until the first run of the app. |\n\n### Guidelines for implementation\n\nFor reference implementation, refer to\n[notification service](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/services/core/java/com/android/server/notification/),\n[permission service](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/services/core/java/com/android/server/pm/permission/) and\n[policy service](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/services/core/java/com/android/server/policy). To implement exceptions\nfor default permission handlers see\n[Runtime Permissions](/docs/core/permissions/runtime_perms#integration).\n\nDuring implementation, use the following guidelines on user notification\nbehavior for apps targeting Android 13 or lower SDKs:\n\n- Freshly installed apps on an Android 13 device must not send a notification without the user approving a permission prompt.\n - If the app targets versions Android 13 and higher, notifications must be blocked until prompted by the app as the app controls when and if to ask for user permission.\n - If the app targets versions lower than Android 13, notifications must be blocked until prompted by the OS. The OS must show the permission prompt on the first run of the app.\n- Any app that existed on the device prior to an upgrade to\n Android 13, or any app that was restored through backup\n and restore, must be allowed to send notifications until the first time the user\n launches an activity from that app.\n\n - For apps that target SDK of versions Android 13\n and higher, if the user hasn't previously customized notification settings for\n this app at the app or `NotificationChannel` level, revoke the temporary\n permission grant. Apps must then ask the user for permission before being\n allowed to continue to send notifications.\n\n If an upgraded app targeting Android 13 doesn't\n currently have the notification permission through the temporary upgrade\n grant, and the user has launched it at least once, the app must show a\n notification permission prompt before it's allowed to run any further foreground\n services.\n - For apps that have a target SDK of versions lower than\n Android 13,\n [intercept](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/services/core/java/com/android/server/wm/ActivityInterceptorCallback.java)\n the first activity launch after the app has created at least one `NotificationChannel`\n to show a permission prompt asking if the user wants to receive notifications\n from the app.\n\n If a user previously customized notification settings at the\n app or `NotificationChannel` level for an app on the upgrading device or in a\n backup being restored to the device, the app level setting must be migrated into\n the permission system with the `FLAG_PERMISSION_USER_SET` flag. No further\n notification permission prompt must be shown to the user unless the app\n specifically asks it to be.\n- Backup and restore must be backward and forward compatible between an\n Android 13 device and a device from an earlier OS\n version. Backup data generated from an Android 13\n device must restore onto an earlier OS version, and backup data from an earlier\n OS version must restore onto an Android 13 device.\n\n- Media notifications associated with ongoing media playback must be exempt\n from the notification permission.\n\nValidate changes to the notification and permission systems\n-----------------------------------------------------------\n\nTo validate the implementation, run the following tests:\n\n- Unit tests as specified in [`PreferencesHelperTest`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java),\n [`NotificationManagerServiceTest`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java).\n\n- Any manual test that tests upgrades and backup and restore.\n\n- Any CTS Permission and Notification system test that sends notifications.\n Some of these tests are located in [cts/tests/tests/permission/](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/modules/Permission/tests/cts/permission/src/android/permission/cts/),\n [NotificationManagerTest.java](https://cs.android.com/android/platform/superproject/+/android-latest-release:cts/tests/tests/notification/src/android/app/notification/current/cts/NotificationManagerTest.java?q=NotificationManagerTest.java),\n and [cts/tests/tests/notificationlegacy/](https://cs.android.com/android/platform/superproject/+/android-latest-release:cts/tests/tests/notificationlegacy/)."]]