Hi Nihilitik
I’ve implemented the Android notifications, and it’s working fine. But there is a small problem that I hope you know how to get fixed. When I set the notifications, there are always 2 firing immediately. Thereafter it works like it’s suppose to work. Here’s my code:
public void CreateNotification()
{
DateTime date01 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 08, 00, 00);
DateTime date02 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 13, 00, 00);
DateTime date03 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 19, 00, 00);
SendRepeatingNotification(1, date01, Language.Get("Notification_Header01"), Language.Get("Notification_Message01"), new Color32(18, 115, 196, 255));
SendRepeatingNotification(2, date02, Language.Get("Notification_Header01"), Language.Get("Notification_Message01"), new Color32(18, 115, 196, 255));
SendRepeatingNotification(3, date03, Language.Get("Notification_Header01"), Language.Get("Notification_Message01"), new Color32(18, 115, 196, 255));
}
public static void SendRepeatingNotification(int id, DateTime fireDate, string title, string message, Color32 bgColor, bool sound = true, bool vibrate = true, bool lights = true, string bigIcon = "")
{
long delay =(long) (fireDate - DateTime.Now).TotalSeconds;
long rep = 60 * 60 * 24;
#if UNITY_ANDROID && !UNITY_EDITOR
AndroidJavaClass pluginClass = new AndroidJavaClass(fullClassName);
if (pluginClass != null)
{
pluginClass.CallStatic("SetRepeatingNotification", id, unityClass, delay * 1000L, title, message, message, rep * 1000, sound ? 1 : 0, vibrate ? 1 : 0, lights ? 1 : 0, bigIcon, "notify_icon_small", bgColor.r * 65536 + bgColor.g * 256 + bgColor.b);
}
#endif
}