2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
수신 동의 알림용 알림 권한
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android 13의 알림에서는 수신 동의 모델을 사용하며 이는 수신 해제 모델을 사용하는 이전 Android 버전에서 달라진 점입니다. Android 13에서는 모든 앱이 알림 메시지를 보내기 전에 사용자에게 권한을 요청해야 합니다. 이 모델을 통해 알림 중단을 줄일 수 있고 정보 과부하를 최소화하며 중요한 정도에 따라 표시되는 알림을 사용자가 제어할 수 있습니다. 수신 동의 모델을 지원하려면 OEM은 알림 및 런타임 권한 시스템의 변경사항을 구현해야 합니다.
이 페이지에서는 이러한 변경사항을 지원하기 위해 OEM이 구현해야 하는 내용과 구현을 검증하는 방법을 설명합니다.
수신 동의 알림 변경사항 구현
Android 13부터는 앱이 알림을 보내려면 시스템에서 android.permission.POST_NOTIFICATION
런타임 권한을 요청하여 알림을 보낼 인텐트를 선언해야 합니다.
Android 13 이상에서는 앱이 사용자에게 알림을 보낼 수 있는지 결정하는 설정이 권한 시스템에 저장됩니다.
Android 13 전에는 이 설정이 알림 시스템에 저장되었습니다. 따라서 OEM은 앱이 알림을 보낼 수 있는지에 관한 기존 알림 데이터를 알림 시스템에서 런타임 권한 시스템으로 이전해야 합니다. 또한 OEM은 해당 데이터를 앱 개발자에게 표시하는 기존 API를 알림 시스템에 유지해야 합니다.
알림 및 권한 시스템 변경사항은 사용자 알림 동작의 수신 동의 모델을 기반으로 하며 구현 가이드라인 섹션에 설명되어 있습니다.
수신 동의 모델의 사용자 알림 동작
다음 표는 Android 13을 실행하는 기기에서 다양한 앱 버전의 알림 동작을 보여줍니다.
Android 13을 실행하는 기기 |
Android 13 이상을 타겟팅하는 앱 |
Android 13보다 낮은 버전을 타겟팅하는 앱 |
새로 설치 |
앱에서 메시지를 표시할 때까지 알림이 차단됩니다.
앱에서 권한을 요청할 시기를 제어합니다.
|
OS에서 메시지를 표시할 때까지 알림이 차단됩니다.
앱을 처음 실행할 때 권한을 요청합니다.
|
기존 앱(업그레이드)
|
앱에서 메시지를 표시할 때까지 알림이 허용됩니다.
앱이 첫 번째 적격한 실행에서 요청할 때까지 임시 권한이 부여됩니다.
|
OS에서 메시지를 표시할 때까지 알림이 허용됩니다.
앱을 처음 실행할 때까지 임시 권한이 부여됩니다.
|
구현 가이드라인
참조 구현은 알림 서비스, 권한 서비스, 정책 서비스를 참고하세요. 기본 권한 핸들러의 예외를 구현하려면 런타임 권한을 참고하세요.
구현하는 동안 Android 13 이하 SDK를 타겟팅하는 앱의 사용자 알림 동작에 관한 다음 가이드라인을 사용하세요.
- Android 13 기기에 새로 설치된 앱은 사용자가 권한 요청을 승인하지 않으면 알림을 보내서는 안 됩니다.
- Android 13 이상을 타겟팅하는 앱의 경우 앱에서 메시지를 표시할 때까지 알림을 차단해야 합니다. 앱이 사용자 권한을 요청할지 여부와 시기를 제어하기 때문입니다.
- 앱이 Android 13보다 낮은 버전을 타겟팅하는 경우 OS에서 메시지를 표시할 때까지 알림을 차단해야 합니다. OS는 앱을 처음 실행할 때 권한 메시지를 표시해야 합니다.
Android 13으로 업그레이드하기 전에 기기에 있던 앱 또는 백업과 복원을 통해 복원된 앱은 사용자가 해당 앱에서 처음 활동을 실행할 때까지 알림을 보낼 수 있어야 합니다.
Android 13 이상 버전의 SDK를 타겟팅하는 앱의 경우 사용자가 이전에 앱 또는 NotificationChannel
수준에서 이 앱의 알림 설정을 맞춤설정하지 않았다면 임시 권한 부여를 취소합니다. 그런 다음 앱에서 사용자에게 권한을 요청해야 알림을 계속 보낼 수 있습니다.
Android 13을 타겟팅하는 업그레이드된 앱에 현재 임시 업그레이드 부여를 통한 알림 권한이 없고 사용자가 앱을 한 번 이상 실행했다면 앱에서는 알림 권한 메시지를 표시해야 추가 포그라운드 서비스를 실행할 수 있습니다.
Android 13보다 낮은 버전의 타겟 SDK가 있는 앱의 경우 앱이 NotificationChannel
을 하나 이상 만든 후 첫 번째 활동 실행을 가로채 사용자가 앱에서 알림을 수신할지 묻는 권한 메시지를 표시합니다.
사용자가 이전에 업그레이드 기기에서 또는 기기로 복원된 백업에서 앱의 앱 수준이나 NotificationChannel
수준에서 알림 설정을 맞춤설정했다면 앱 수준 설정은 FLAG_PERMISSION_USER_SET
플래그를 사용하여 권한 시스템으로 이전해야 합니다. 앱에서 구체적으로 요청하지 않는 한 추가 알림 권한 메시지가 사용자에게 표시되어서는 안 됩니다.
백업 및 복원은 Android 13 기기와 이전 OS 버전 기기 간에 하위 및 향후 호환되어야 합니다. Android 13 기기에서 생성된 백업 데이터는 이전 OS 버전으로 복원해야 하며 이전 OS 버전의 백업 데이터는 Android 13 기기로 복원해야 합니다.
진행 중인 미디어 재생과 관련된 미디어 알림은 알림 권한에서 제외되어야 합니다.
알림 및 권한 시스템 변경사항 확인
구현을 확인하려면 다음 테스트를 실행합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2024-08-07(UTC)
[[["이해하기 쉬움","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"]],["최종 업데이트: 2024-08-07(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/)."]]