알림 권한 요청 | Push | Appbox Android SDK 가이드

알림 권한 요청

시스템 알림 권한을 요청합니다. 온보딩이나 푸시 설정 화면에서 사용자에게 권한을 물을 때 호출합니다.

알림 권한 요청

AppBox.requestPushPermission(activity, callback)

Kotlin
1 AppBox.requestPushPermission(this) { granted, error ->
2 when {
3 error is AppBoxPushPromptInterruptedException -> Unit // 거부가 아님
4 granted == true -> enablePushUi()
5 else -> showNotificationSettingsGuide()
6 }
7 }
1 AppBox.requestPushPermission(this, new AppBoxValueCallback<Boolean>() {
2 @Override
3 public void onComplete(Boolean granted, Throwable error) {
4 if (error instanceof AppBoxPushPromptInterruptedException) {
5 return; // 거부가 아님
6 }
7 if (Boolean.TRUE.equals(granted)) {
8 enablePushUi();
9 } else {
10 showNotificationSettingsGuide();
11 }
12 }
13 });

Request 항목 정의

Request 항목필수여부설명기본값
activity필수권한 다이얼로그를 표시할 foreground Activity. Application context는 쓸 수 없습니다-
callback필수AppBoxValueCallback<Boolean>-


Response 항목 정의

Response 결과값
granted = true, error = null사용자가 허용
granted = false, error = null사용자가 거부
granted = null, error = AppBoxPushPromptInterruptedException사용자가 응답하지 않고 프롬프트가 종료됨
오류AppBoxPushPromptInterruptedException: 홈 화면 이동, 화면 잠금으로 프롬프트가 응답 없이 닫힘


응답 없이 종료된 상태를 거부로 저장하지 마세요. 사용자의 의사 표시가 아니며, 거부로 저장하면 사용자를 잘못 옵트아웃시킵니다. Android 13 이상에서는 시스템 다이얼로그가 표시됩니다. Android 12 이하에서는 다이얼로그 없이 현재 알림 활성화 상태가 반환됩니다. 예외적으로 appbox-push artifact만 있으면 동작합니다.

www.naver.com
QR 코드를 촬영하면 입력하신 주소의
앱 예시 화면을 테스트할 수 있습니다.
* 스캔 후 바로 앱 다운로드 이동합니다.