public override void Control(Entity entity, EntityUniverseFacade facade, ControlState main, ControlState alt) { if (!main.DownClick) { return; } if (entity.PlayerEntityLogic.LookingAtTile(out var target, out _)) { if (facade.TryGetLightPower(target, out var efficiency, out var phase, out var reductions)) { var notificationParams = new NotificationParams(3); notificationParams.SetString(0, efficiency + "%"); notificationParams.SetFloat(1, phase); notificationParams.SetFloat(2, reductions); var notification = GameContext.NotificationDatabase.CreateNotificationFromCode( "nimbusfox.powerapi.notifications.lightInformation", facade.Step, notificationParams, true); entity.PlayerEntityLogic.ShowNotification(notification); } } }
public void ScheduleFutureNotification(int seconds) { #if UNITY_ANDROID NotificationParams notification = new NotificationParams { Id = NotificationIdHandler.GetNotificationId(), Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, LargeIcon = "app_icon", SmallIcon = NotificationIcon.Coin, SmallIconColor = new Color(0, 0.5f, 0), CallbackData = "ScheduleFutureNotification", // name of method Delay = TimeSpan.FromSeconds(seconds), Title = androidAppTitle, Message = string.Format(scheduledEventNotificationMessage) }; NotificationManager.SendCustom(notification); #elif UNITY_IOS //LocalNotification notification = new LocalNotification //{ // applicationIconBadgeNumber = 1, // alertBody = string.Format(scheduledEventNotificationMessage, giftName), // fireDate = DateTime.Now.AddSeconds(seconds), // soundName = LocalNotification.defaultSoundName //}; //NotificationServices.ScheduleLocalNotification(notification); #endif }
public void ScheduleNotification(int id, TimeSpan fire_delay, string title_text, string body_text, NotificationIcon icon, string large_icon, string custom_sound = null) { NotificationParams notificationParams = new NotificationParams { Id = id, Delay = fire_delay, Message = body_text, Sound = true, Multiline = true, Ticker = body_text, Vibrate = true, //Light = true, //LightOnMs = 1000, //LightOffMs = 1000, //LightColor = Color.red, SmallIcon = icon, //SmallIconColor = new Color(0f, 0.5f, 0f), LargeIcon = large_icon, ExecuteMode = NotificationExecuteMode.Inexact, }; if (custom_sound != null) { notificationParams.CustomSound = custom_sound; } if (title_text != null) { notificationParams.Title = title_text; } Assets.SimpleAndroidNotifications.NotificationManager.SendCustom(notificationParams); Debug.LogFormat("Local Android notification scheduled for {0}: {1}", DateTime.Now + fire_delay, body_text); }
public void ScheduleComeback(DateTime notifyAt) { if (!notificationSet) { cancelComeBackNotification(); TimeSpan waitTime = notifyAt - DateTime.Now; var notificationParams = new NotificationParams { Id = 42, //Id = UnityEngine.Random.Range(0, int.MaxValue), Delay = TimeSpan.FromHours(waitTime.Hours), Title = "We miss you", Message = "Pease come back", Ticker = "Ticker", Sound = true, Vibrate = false, Light = true, SmallIcon = NotificationIcon.Heart, SmallIconColor = new Color(0.7f, 0.5f, 0), LargeIcon = "app_icon" }; NotificationManager.SendCustom(notificationParams); notificationSet = true; } }
public void spin() { if (PlayerPrefs.GetInt("spin") > 0) { musicManager.UISFX(3); PlayerPrefs.SetString("spinTime", DateTime.Now.ToString()); PlayerPrefs.SetInt("spin", PlayerPrefs.GetInt("spin") - 1); triangl.transform.SetParent(wheelOfFortuneSelection.transform, true); StartCoroutine(wheelTurned()); dailySpinTime(); if (PlayerPrefs.GetInt("notifications") == 0) { var notificationParams = new NotificationParams { Id = Random.Range(0, int.MaxValue), Delay = TimeSpan.FromDays(1), Title = "Daily Spin :3", Message = "Your Daily Spin is Ready, Go Catch sheeps !", Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, SmallIcon = NotificationIcon.Heart, SmallIconColor = new Color(0, 0.5f, 0), LargeIcon = "app_icon" }; NotificationManager.CancelAll(); NotificationManager.SendCustom(notificationParams); } } }
public MessageResult sendNotificationAll(String notificationContent) { NotificationParams notifyParams = new NotificationParams(); notifyParams.ReceiverType = ReceiverTypeEnum.APP_KEY; return(_pushClient.sendNotification(notificationContent, notifyParams, null)); }
// Call by main game OnApplicationPause public void ScheduleReturnBackToGameNotification() { #if UNITY_ANDROID NotificationParams notification = new NotificationParams { Id = NotificationIdHandler.GetNotificationId(), Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, LargeIcon = "app_icon", SmallIcon = NotificationIcon.Heart, SmallIconColor = new Color(0, 0.5f, 0), CallbackData = "ScheduleReturnBackToGameNotification", // name of method Delay = TimeSpan.FromSeconds(inactiveLatelyNotificationDelayInSeconds), Title = androidAppTitle, Message = inactiveLatelyMessage }; NotificationManager.SendCustom(notification); #elif UNITY_IOS LocalNotification notification = new LocalNotification { applicationIconBadgeNumber = 1, alertBody = inactiveLatelyMessage, fireDate = DateTime.Now.AddSeconds(inactiveLatelyNotificationDelayInSeconds), soundName = LocalNotification.defaultSoundName }; NotificationServices.ScheduleLocalNotification(notification); #endif }
private void SendFullTicketsNotification() { int tickets = PlayerPrefs.GetInt("Tickets"); if (tickets < 5) { var time = ((5 - tickets) * 20 * 60); if (PlayerPrefs.HasKey("TicketDecrementedTime")) { var TimeDecremented = Convert.ToDateTime(PlayerPrefs.GetString("TicketDecrementedTime")); var CurrentTime = DateTime.Now; var TimeDifference = CurrentTime - TimeDecremented; time = ((5 - tickets) * 20 * 60) - TimeDifference.Seconds; } var notificationParams = new NotificationParams { Id = UnityEngine.Random.Range(0, int.MaxValue), Delay = TimeSpan.FromSeconds(time), Title = "Full Tickets", Message = "You have full tickets now", Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, SmallIcon = NotificationIcon.Heart, SmallIconColor = new Color(0, 0.5f, 0), LargeIcon = "app_icon" }; NotificationManager.SendCustom(notificationParams); } }
private void sendNotification(int id, TimeSpan delay, string title, string text, Color32 color) { var notificationParams = new NotificationParams { Id = id, Delay = delay, Title = title, Message = text, //Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, SmallIcon = NotificationIcon.Bell, SmallIconColor = new Color(0.5f, 0.5f, 0.5f), LargeIcon = "app_icon" }; NotificationManager.SendCustom(notificationParams); //NotificationManager.SendWithAppIcon(delay, title, text, new Color(0, 0.6f, 1), NotificationIcon.Bell); //NotificationManager.Send(delay, title, text, new Color(0, 0.6f, 1)); //LocalNotification.SendNotification(id, delay, title, text, color); #if UNITY_IOS if (Application.platform == RuntimePlatform.IPhonePlayer) { UnityEngine.iOS.LocalNotification notification = new UnityEngine.iOS.LocalNotification(); notification.fireDate = DateTime.Now.Add(delay); notification.alertAction = "Alert"; notification.alertBody = text; notification.hasAction = false; NotificationServices.ScheduleLocalNotification(notification); } #endif }
private void Process(NotificationParams p, RetentionNotification note) { p.Title = note.title; p.Message = note.message; p.SmallIcon = icon; p.LargeIcon = note.icon; p.Vibrate = false; p.Multiline = true; p.Repeat = true; }
public void ScheduleDebug(RetentionNotification note) { var notificationParams = new NotificationParams { Id = GetId(100), Delay = TimeSpan.FromSeconds(10), ExecuteMode = NotificationExecuteMode.ExactAndAllowWhileIdle, RepeatInterval = TimeSpan.FromSeconds(30) }; Process(notificationParams, note); NotificationManager.SendCustom(notificationParams); }
/// <summary> /// Schedule customizable notification. /// </summary> public static int SendCustom(NotificationParams notificationParams) { #if UNITY_ANDROID && !UNITY_EDITOR var p = notificationParams; var delay = (long)p.Delay.TotalMilliseconds; new AndroidJavaClass(FullClassName).CallStatic("SetNotification", p.Id, delay, p.Title, p.Message, p.Ticker, p.Sound ? 1 : 0, p.Vibrate ? 1 : 0, p.Light ? 1 : 0, p.LargeIcon, GetSmallIconName(p.SmallIcon), ColotToInt(p.SmallIconColor), MainActivityClassName); #else Debug.LogWarning("Simple Android Notifications are not supported for current platform. Build and play this scene on android device!"); #endif return(notificationParams.Id); }
public void Schedule(DayOfWeek day, RetentionNotification note, DateTime date) { var delay = date - DateTime.Now; var notificationParams = new NotificationParams { Id = GetId((int)day), Delay = delay, ExecuteMode = NotificationExecuteMode.Inexact, RepeatInterval = TimeSpan.FromDays(7) }; Process(notificationParams, note); NotificationManager.SendCustom(notificationParams); }
private void OnApplicationPause(bool isPause) { try { if (isPause) { int num = UnityEngine.Random.Range(1, 5); string textByKey = LocalizationService.Instance.GetTextByKey("localNotification_0" + num + "_title"); string textByKey2 = LocalizationService.Instance.GetTextByKey("localNotification_0" + num + "_body"); NotificationParams notificationParams = new NotificationParams { Id = NotificationIdHandler.GetNotificationId(), Delay = TimeSpan.FromHours(24.0), Title = textByKey, Message = textByKey2, Ticker = textByKey, Sound = true, Vibrate = true, Light = true, SmallIcon = NotificationIcon.Bell, SmallIconColor = new Color(0.63f, 0.63f, 0.63f), LargeIcon = "app_icon", ExecuteMode = NotificationExecuteMode.Inexact, Importance = NotificationImportance.Max, Repeat = true, RepeatInterval = TimeSpan.FromHours(24.0), ChannelId = "coloring.local", ChannelName = "Miscellaneous" }; NotificationManager.SendCustom(notificationParams); } else { NotificationCallback notificationCallback = NotificationManager.GetNotificationCallback(); if (notificationCallback != null && notificationCallback.Id != this.lastNotifId) { this.lastNotifId = notificationCallback.Id; AppState.LocalNotificationLaunch = true; FMLogger.vCore("local notif app resume"); } NotificationManager.CancelAll(); } } catch (Exception ex) { FMLogger.vCore("NotificationManager resume handler ex. " + ex.Message); } }
public static void SetTutorialNotifications() { var waitForSeconds = TimeManager.Instance.WaitForSeconds; var year = TimeManager.Instance.Year; var month = TimeManager.Instance.Month; var events = EventManager.Instance.EventsArray; foreach (var eventsio in events) { int monthCount = 0; int yearGap = eventsio.Starts.y - year; monthCount += (yearGap * 12); if (yearGap > 0) { monthCount += eventsio.Starts.x; monthCount += (12 - month); } else { monthCount += (eventsio.Starts.x - month); } Debug.Log(monthCount); var notificationParams = new NotificationParams { Id = Random.Range(0, int.MaxValue), Delay = TimeSpan.FromSeconds(monthCount * waitForSeconds), Title = eventsio.Headline, MessageEntry = "New event started " + eventsio.Headline, Ticker = "", Sound = true, Vibrate = true, Light = true, SmallIcon = NotificationIcon.Message, SmallIconColor = new Color(0, 0.5f, 0), LargeIcon = "app_icon" }; NotificationManager.SendCustom(notificationParams); } }
public async Task <IActionResult> GetAllForCurrentUser([FromQuery] NotificationParams notificationParams) { var result = await notificationService.GetNotificationsForUser(await userManager.FindByNameAsync(User.Identity.Name), notificationParams); var metadata = new { result.TotalCount, result.PageSize, result.CurrentPage, result.TotalPages, result.HasNext, result.HasPrevious }; Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata)); return(Ok(result)); }
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 async Task <IActionResult> GetAllNotifications([FromQuery] NotificationParams notificationParams) { var result = await notificationService.GetNotifications(notificationParams); var metadata = new { result.TotalCount, result.PageSize, result.CurrentPage, result.TotalPages, result.HasNext, result.HasPrevious }; Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata)); return(Ok(result)); }
public static void ScheduleMissionCompleteNotification(string missionName, int badgeNumber, long secondsFromNow) { if (secondsFromNow < (long)0) { return; } NotificationParams notificationParam = new NotificationParams() { Delay = TimeSpan.FromSeconds((double)secondsFromNow), Title = StaticDB.GetString("MISSION_COMPLETE2", null), Message = missionName, SmallIconColor = Color.black, SmallIcon = NotificationIcon.Mission, Sound = true, CustomSound = "ui_mission_complete_toast_n" }; NotificationManager.SendCustom(notificationParam); }
public static void ScheduleTalentResearchCompleteNotification(string talentName, int badgeNumber, long secondsFromNow) { if (secondsFromNow < (long)0) { return; } NotificationParams notificationParam = new NotificationParams() { Delay = TimeSpan.FromSeconds((double)secondsFromNow), Title = StaticDB.GetString("RESEARCH_COMPLETE", null), Message = talentName, SmallIconColor = Color.black, SmallIcon = NotificationIcon.Talent, Sound = true, CustomSound = "ui_orderhall_talent_ready_toast_n" }; NotificationManager.SendCustom(notificationParam); }
public static void ScheduleWorkOrderReadyNotification(string workOrderName, int badgeNumber, long secondsFromNow) { if (secondsFromNow < (long)0) { return; } NotificationParams notificationParam = new NotificationParams() { Delay = TimeSpan.FromSeconds((double)secondsFromNow), Title = StaticDB.GetString("READY_FOR_PICKUP", null), Message = workOrderName, SmallIconColor = Color.black, SmallIcon = NotificationIcon.WorkOrder, Sound = true, CustomSound = "ui_mission_troops_ready_toast_n" }; NotificationManager.SendCustom(notificationParam); }
// Call by main game OnApplicationPause public void ScheduleOneDayNotification() { string dayNotificationScheduleTime = PlayerPrefs.GetString(Constants.Notifications.DayNotificationScheduleTime, ""); if (dayNotificationScheduleTime != "") { DateTime scheduledOneDayNotificationTime = DateTime.ParseExact(dayNotificationScheduleTime, "yyyyMMddHHmmss", CultureInfo.CurrentCulture); TimeSpan timeSpan = scheduledOneDayNotificationTime - DateTime.Now; if (timeSpan.TotalSeconds > 0) { #if UNITY_ANDROID NotificationParams notification = new NotificationParams { Id = NotificationIdHandler.GetNotificationId(), Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, LargeIcon = "app_icon", SmallIcon = NotificationIcon.Heart, SmallIconColor = new Color(0, 0.5f, 0), Delay = TimeSpan.FromSeconds(timeSpan.TotalSeconds), Title = androidAppTitle, Message = Random24HourMessage() }; NotificationManager.SendCustom(notification); #elif UNITY_IOS if (notificationsOn) { LocalNotification notification = new LocalNotification { applicationIconBadgeNumber = 1, alertBody = Random24HourMessage(), fireDate = DateTime.Now.AddSeconds(timeSpan.TotalSeconds), soundName = LocalNotification.defaultSoundName }; NotificationServices.ScheduleLocalNotification(notification); } #endif } } }
private void SendWeeklyNotification() { var weeklyNotificationParams = new NotificationParams { Id = UnityEngine.Random.Range(0, int.MaxValue), Delay = TimeSpan.FromSeconds(7 * 24 * 60 * 60), Title = "Color Snipers U", Message = "Its been a week since you battled against the Color Snipers! Tap to send colors back to soldiers!", Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, SmallIcon = NotificationIcon.Heart, SmallIconColor = new Color(0, 0.5f, 0), LargeIcon = "app_icon" }; NotificationManager.SendCustom(weeklyNotificationParams); }
private void SendDailyNotification() { var dailyNotificationParams = new NotificationParams { Id = UnityEngine.Random.Range(0, int.MaxValue), Delay = TimeSpan.FromSeconds(24 * 60 * 60), Title = "Color Snipers U", Message = "Keep quit and just close the windows!", Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, SmallIcon = NotificationIcon.Heart, SmallIconColor = new Color(0, 0.5f, 0), LargeIcon = "app_icon" }; NotificationManager.SendCustom(dailyNotificationParams); }
private void SendMonthlyNotification() { var monthlyNotificationParams = new NotificationParams { Id = UnityEngine.Random.Range(0, int.MaxValue), Delay = TimeSpan.FromSeconds(30 * 24 * 60 * 60), Title = "Color Snipers U", Message = "Come back and show the power of closing Windows!", Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, SmallIcon = NotificationIcon.Heart, SmallIconColor = new Color(0, 0.5f, 0), LargeIcon = "app_icon" }; NotificationManager.SendCustom(monthlyNotificationParams); }
public void ScheduleBoxNotification(DateTime notifyAt) { TimeSpan waitTime = notifyAt - DateTime.Now; var notificationParams = new NotificationParams { Id = UnityEngine.Random.Range(0, int.MaxValue), Delay = TimeSpan.FromSeconds(waitTime.TotalSeconds), Title = "It's time!", Message = "Get the box!", Ticker = "Ticker", Sound = true, Vibrate = false, Light = true, SmallIcon = NotificationIcon.Heart, SmallIconColor = new Color(0.7f, 0.5f, 0), LargeIcon = "app_icon" }; NotificationManager.SendCustom(notificationParams); }
private static void AddUpgradeEvent(int upgradeDuration) { var waitForSeconds = TimeManager.Instance.WaitForSeconds; var notificationParams = new NotificationParams { Id = Random.Range(0, int.MaxValue), Delay = TimeSpan.FromSeconds(waitForSeconds * upgradeDuration), Title = "Upgrade has ended", MessageEntry = "Your upgrade has ended", Ticker = "geld", Sound = true, Vibrate = true, Light = true, SmallIcon = NotificationIcon.Event, SmallIconColor = new Color(0, 0.5f, 0), LargeIcon = "app_icon" }; NotificationManager.SendCustom(notificationParams); }
public void ScheduleNotification(TimeSpan timeToShow, string message = "Your daily bonus is available!") { var notificationParams = new NotificationParams { Id = UnityEngine.Random.Range(0, int.MaxValue), Delay = timeToShow, Title = "Jacks or Better", Message = message, Ticker = "Collect your bonus!", Sound = true, Vibrate = true, Light = false, SmallIcon = NotificationIcon.Bell, SmallIconColor = new Color(0, 0.5f, 0), LargeIcon = "app_icon" }; Debug.Log("Started notification at: " + (DateTime.Now + timeToShow).ToString()); NotificationManager.SendCustom(notificationParams); }
public void ScheduleFilmReplenishmentNotification(double secondsUntilFull) { if ((int)secondsUntilFull > 0) { if (notificationsOn) { secondsUntilFull = Mathf.Round((float)BedtimeCheck(secondsUntilFull)); #if UNITY_ANDROID NotificationParams notification = new NotificationParams { Id = NotificationIdHandler.GetNotificationId(), Ticker = "Ticker", Sound = true, Vibrate = true, Light = true, LargeIcon = "app_icon", SmallIcon = NotificationIcon.Event, SmallIconColor = new Color(0, 0.5f, 0), Delay = TimeSpan.FromSeconds(secondsUntilFull), Title = androidAppTitle, Message = RandomFilmReplenishmentMessage() }; NotificationManager.SendCustom(notification); #elif UNITY_IOS LocalNotification notification = new LocalNotification { applicationIconBadgeNumber = 1, alertBody = RandomFilmReplenishmentMessage(), fireDate = DateTime.Now.AddSeconds((int)secondsUntilFull), soundName = LocalNotification.defaultSoundName }; NotificationServices.ScheduleLocalNotification(notification); #endif } } }
/// <summary> /// 发送通知 /// </summary> /// <param name="notificationContent">通知内容</param> /// <param name="notifyParams"></param> /// <param name="extras"></param> /// <returns></returns> public MessageResult sendNotification(String notificationContent, NotificationParams notifyParams, String extras) { return(_pushClient.sendNotification(notificationContent, notifyParams, extras)); }