개요
유니티 플러그인
사용방법
1. 알림 아이콘 적용
Project Folder/Assets/Plugins/Android/DasonyNotification/res/drawable/
1-1 해상도(dpi) 별 drawable 폴더명
drawable
drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
2. 로컬 알림 설정
using Dasony.Libs;2-1 초기화
public class Test : MonoBehaviour {
LocalNotification notification;
void Start () {
notification = LocalNotification.Instance;
}
}
2-2 알림 보내기
public class Test : MonoBehaviour {
...
void SendNotification () {
NotificationData.Builder builder = new Notification.Builder(1) // 정수형 알림 id
.SetSmallIcon ("notify_icon") // 위에서 추가한 아이콘의 이름
.SetContentTitle("제목 입력")
.SetContentText("본문 입력")
.SetAutoCancel(true)
.SetDelay(30000); // 30초 후에 알림 옴, 단위는 밀리초
notification.SetLocalNotification(builder.Build()); // 알림을 보냅니다.
}
}
2-3 알림 취소 (스케쥴 알림 이용 시)
notification.CancelScheduleNotification(1); // 알림 생성 시 입력했던 정수형 알림 idnotification.CancelAllScheduleNotification();2-4 수신된 모든 알림 없애기
notification.ClearAllLocalNotifications();3. 레퍼런스
Notification (Dasony.Libs.Notification)
정리
Notification ()
사용자가 직접 생성자를 호출 할 수 없습니다.
Notification.Instance 를 이용하여 메서드를 호출해야 합니다.
TestNotification(long delay)
알림이 정상 동작하는지 테스트 할 때 호출하기 위한 용도입니다 .
제목 : Test
내용 : Test Notification!
위의 내용으로 알림이 설정됩니다.
delay 값을 입력하면 스케쥴 알림으로 설정됩니다.
SetLocalNotification (NotificationData data)
NotificationData로 생성된 알림 데이터를 이용하여 로컬 알림을 설정합니다.
CancelScheduleNotification (int id)
스케쥴 알림으로 설정된 알림을 취소 처리합니다.
id는 NotificationData를 생성할 때 입력한 id를 사용합니다.
CancelAllScheduleNotifications ()
스케쥴 알림으로 설정된 모든 알림을 취소 처리합니다.
CancelAllScheduleNotifications ()
스케쥴 알림으로 설정된 모든 알림을 취소 처리합니다.
ClearAllLocalNotifications ()
호출 처리된 모든 알림을 제거합니다.
이때 앱 아이콘에 노출된 배지도 함께 제거됩니다.
ClearAllLocalNotifications ()
호출 처리된 모든 알림을 제거합니다.
이때 앱 아이콘에 노출된 배지도 함께 제거됩니다.
NotificationData.Builder (Dasony.Libs.NotificationData.Builder)
정리
NotificationData.Builder (int id, ChannelData channelData = null)
id : 정수형 알림 id
channelData : 최근 안드로이드 라이브러리에 추가된 내용으로 알림을 그룹화 함 (null 가능)
SetContentTitle (string value)
일반적인 알림의 제목을 설정합니다.
SetContentText (string value)
일반적인 알림의 내용을 설정합니다.
SetContentTicker (string value)
알림 수신 시 노치에 표시되는 한 줄 내용을 설정합니다.
SetSmallIcon (string iconName)
알림에 노출 될 작은 크기의 아이콘을 설정합니다. (필수)
SetLargeIcon (string iconName)
알림에 노출 될 큰 크기의 아이콘을 설정합니다. (선택)
SetColor (Color32 color)
알림에 노출 되는 작은 크기의 아이콘의 색상을 변경합니다.
SetBadgeIconType (int type)
앱 아이콘 위에 노출되는 배지의 형태를 설정합니다.
SetPriority (int priority)
알림의 우선 순위를 설정합니다.
SetDelay (long milliSecond)
알림을 지연시킵니다. 흔히 스케쥴 알림이라고 말합니다.
SetAutoCancel (bool value)
true로 설정할 경우 사용자가 알림을 터치하면 노치에서 자동으로 알림이 제거됩니다.
마치며
'Develop > Plug-in' 카테고리의 다른 글
| [NATIVE, ANDROID] Android 6.0 (마쉬멜로우) 이상에서 Permission (시스템 권한) 체크 및 유니티 플러그인 (7) | 2018.11.08 |
|---|
notify-1.0.0.unitypackage