private LocalNotification NewNotification(string message, DateTime time, CalendarUnit interval) { LocalNotification ntf = NewNotification(message, time); ntf.repeatInterval = interval; return(ntf); }
public static CalendarUnit convertToCalendarUnit(float hours) { CalendarUnit unit = CalendarUnit.Year; if (hours < 24) { unit = CalendarUnit.Hour; } else if (hours >= 24 && hours < 48) { unit = CalendarUnit.Day; } else if (hours >= 48 && hours < 168) { unit = CalendarUnit.Weekday; } else if (hours >= 168 && hours < 672) { unit = CalendarUnit.Week; } else if (hours >= 672 && hours <= 744) { unit = CalendarUnit.Month; } else if (hours > 744 && hours <= 2208) { unit = CalendarUnit.Quarter; } return(unit); }
private DateTime RepeatIntervalToDateTime(CalendarUnit repeatInterval) { switch (repeatInterval) { case CalendarUnit.Year: return(System.DateTime.Now.AddYears(1)); case CalendarUnit.Quarter: return(System.DateTime.Now.AddMonths(3)); case CalendarUnit.Month: return(System.DateTime.Now.AddMonths(1)); case CalendarUnit.Week: return(System.DateTime.Now.AddDays(7)); case CalendarUnit.Day: return(System.DateTime.Now.AddDays(1)); case CalendarUnit.Hour: return(System.DateTime.Now.AddHours(1)); case CalendarUnit.Minute: return(System.DateTime.Now.AddMinutes(1)); case CalendarUnit.Second: return(System.DateTime.Now.AddSeconds(1)); default: UnityEngine.Debug.LogWarning("Unexpected repeatInterval: " + repeatInterval); return(System.DateTime.MaxValue); } }
public async Task <CalendarResponse> GetCalendar(DateTime from, CalendarUnit unit, int numberOfUnit) { var response = await Client.GetAsync($"v2/calendar?type={unit}&day={ToFamlyDate(from)}&limit={numberOfUnit}"); if (response.IsSuccessStatusCode) { var res = await response.Content.ReadAsAsync <ICollection <Period> >(); return(new CalendarResponse { Periodes = res }); } return(null); }
protected void ScheduleLocalNotification(string pAlertBody, DateTime pFireDate, CalendarUnit pUnit) { LocalNotification localNotification = new LocalNotification(); localNotification.fireDate = pFireDate; localNotification.alertBody = pAlertBody; localNotification.applicationIconBadgeNumber = 1; localNotification.hasAction = true; localNotification.repeatCalendar = CalendarIdentifier.GregorianCalendar; localNotification.repeatInterval = pUnit; NotificationServices.ScheduleLocalNotification(localNotification); if (IsTestMode) { UnityEngine.Debug.LogErrorFormat("{0}->ScheduleLocalNotification: pAlertBody: {1}], pFireDate: {2}, pUnit: {3}", GetType().Name, pAlertBody, pFireDate, pUnit); } }
//本地推送 你可以传入一个固定的推送时间 static void IOS_NotificationMessage(string message, System.DateTime newDate, bool isRepeatDay, CalendarUnit repeat) { //推送时间需要大于当前时间 //if (newDate > System.DateTime.Now) { LocalNotification localNotification = new LocalNotification(); localNotification.fireDate = newDate; localNotification.alertBody = message; localNotification.applicationIconBadgeNumber = 1; localNotification.hasAction = true; if (isRepeatDay) { //是否每天定期循环 localNotification.repeatCalendar = CalendarIdentifier.ChineseCalendar; localNotification.repeatInterval = repeat; } localNotification.soundName = LocalNotification.defaultSoundName; NotificationServices.ScheduleLocalNotification(localNotification); Debug.Log("Add IOS LocalNotification = " + message + " Time=" + newDate); } }
static void IOS_NotificationMessageRepeat(string message, int hour, int minute, int second, CalendarUnit repeat) { System.DateTime now = System.DateTime.Now; System.DateTime time = new System.DateTime(now.Year, now.Month, now.Day, hour, minute, second); IOS_NotificationMessage(message, time, true, repeat); }