53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
![]() |
using System;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace Assets.SimpleAndroidNotifications
|
|||
|
{
|
|||
|
public class NotificationExample : MonoBehaviour
|
|||
|
{
|
|||
|
public void Rate()
|
|||
|
{
|
|||
|
Application.OpenURL("http://u3d.as/y6r");
|
|||
|
}
|
|||
|
|
|||
|
public void OpenWiki()
|
|||
|
{
|
|||
|
Application.OpenURL("https://github.com/hippogamesunity/SimpleAndroidNotificationsPublic/wiki");
|
|||
|
}
|
|||
|
|
|||
|
public void ScheduleSimple()
|
|||
|
{
|
|||
|
NotificationManager.Send(TimeSpan.FromSeconds(5), "Simple notification", "Customize icon and color", new Color(1, 0.3f, 0.15f));
|
|||
|
}
|
|||
|
|
|||
|
public void ScheduleNormal()
|
|||
|
{
|
|||
|
NotificationManager.SendWithAppIcon(TimeSpan.FromSeconds(5), "Notification", "Notification with app icon", new Color(0, 0.6f, 1), NotificationIcon.Message);
|
|||
|
}
|
|||
|
|
|||
|
public void ScheduleCustom()
|
|||
|
{
|
|||
|
var notificationParams = new NotificationParams
|
|||
|
{
|
|||
|
Id = UnityEngine.Random.Range(0, int.MaxValue),
|
|||
|
Delay = TimeSpan.FromSeconds(5),
|
|||
|
Title = "Custom notification",
|
|||
|
Message = "Message",
|
|||
|
Ticker = "Ticker",
|
|||
|
Sound = true,
|
|||
|
Vibrate = true,
|
|||
|
Light = true,
|
|||
|
SmallIcon = NotificationIcon.Heart,
|
|||
|
SmallIconColor = new Color(0, 0.5f, 0),
|
|||
|
LargeIcon = "app_icon"
|
|||
|
};
|
|||
|
|
|||
|
NotificationManager.SendCustom(notificationParams);
|
|||
|
}
|
|||
|
|
|||
|
public void CancelAll()
|
|||
|
{
|
|||
|
NotificationManager.CancelAll();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|