반응형
Simple Android Notifications Free | 기능 통합 | Unity Asset Store
Use the Simple Android Notifications Free from Hippo on your next project. Find this integration tool & more on the Unity Asset Store.
assetstore.unity.com
에셋 추가로 간단하고 빠르게 푸시알림 구현이 가능하다.
사용 시에는
using Assets.SimpleAndroidNotifications;
를 추가 해줘야한다.
// 앱이 일시정지 되었을 때 1분후에 푸시알림을 보내는 코드
private void OnApplicationPause(bool pause)
{
NotificationManager.CancelAll(); // 모든 알림 삭제
if (pause)
{
isPaused = true;
DateTime dateTime = DateTime.Now.AddMinutes(1);
TimeSpan time = dateTime - DateTime.Now;
NotificationManager.SendWithAppIcon(time, title, content, Color.blue, NotificationIcon.Star);
// 원하는 시간, 제목, 내용, 글자 색, 알림 아이콘 으로 푸시알림 발생
Debug.Log("일시정지");
}
else
{
if (isPaused)
{
isPaused = false;
Debug.Log("일시정지 해제");
}
}
}
// 앱이 꺼졌을 때 1분 후에 푸시알림을 보내는 코드
private void OnApplicationQuit()
{
Debug.Log("게임 종료");
DateTime dateTime = DateTime.Now.AddMinutes(1);
TimeSpan time = dateTime - DateTime.Now;
NotificationManager.SendWithAppIcon(time, title, content, Color.blue, NotificationIcon.Star);
}

반응형
'유니티 > 유니티 C#' 카테고리의 다른 글
[유니티/C#] 라인렌더러를 이용한 움직이는 발판 (0) | 2023.06.16 |
---|---|
[유니티/C#] UI 슬라이드 기능 만들기 (DOTween) (0) | 2023.06.15 |
[유니티/C#] 터치로 화면이동 (0) | 2022.08.07 |
[유니티/C#] 터치/마우스로 카메라 이동 (0) | 2022.08.03 |
[유니티/C#] 아이소메트릭 카메라 설정 (0) | 2022.08.03 |