안드로이드

[안드로이드] Notification의 구성 및 속성

sinw212 2023. 2. 22. 15:39

Notification 구성

Notification 구성

① Small Icon : This is requried and set with setSmallIcon().

② App Name : This is provided by the system.

③ Time stamp : This is provided by the system but you can override with setWhen() or hide it with setShowWhen(false).

④ Large Icon : This is optional (usually used only for contact photos; do not use it for your app icon) and set with setLargeIcon().

⑤ Title : This is optional and set with setContentTitle().

⑥ Text : This is optional and set with setContentText().

 

Notification 속성

  • setColor() : 알림 내 앱 이름 색상 설정
  • setWhen() : 받은 시간 커스텀 (기본 시스템에서 제공)
  • setShowWhen() : 알림 수신 시간 (default값은 true, false 시 숨김)
  • setOnlyAlertOnce() : 알림 1회 수신 (동일 아이디 알림 시 처음만, 상태바에 알림이 잔존하면 무음)
  • setFullScreenIntent() : 긴급 알림
  • setTimeoutAfter() : 알림 자동 사라지기 (지정 시간 후 수신된 알림 사라짐)
  • setContentIntent() : 알림 클릭시 이벤트 (미지정 시, 클릭해도 무반응. setAutoCancel()도 미작동)
  • setLargeIcon() : 큰 아이콘 (mipmap의 아이콘이 아닌, drawable의 아이콘 사용)
  • setAutoCancel() : 알림 클릭 시 삭제 여부 (true = 클릭 시 삭제, false = 클릭해도 미삭제)
  • setPriority() : 알림의 중요도 설정
  • setVisibility() : 잠금 화면 내 알림 노출 여부
    • Notification.VISIBILITY_PRIVATE : 알림의 기본 정보만 노출(제목, 타이틀 등)
    • Notification.VISIBILITY_PUBLIC : 알림의 모든 정보 노출
    • Notification.VISIBILITY_SECRET : 알림의 모든 정보 비노출