/// <summary> /// Show a local notification at a specified time /// </summary> /// <param name="title">Title of the notification</param> /// <param name="body">Body or description of the notification</param> /// <param name="id">Id of the notification</param> /// <param name="notifyTime">Time to show notification</param> public void Show(string title, string body, int id, DateTime notifyTime) { Notification notification = new Notification { Title = title, Content = body, Tag = id.ToString(), }; notificationId = id; Notification.IndicatorStyle style = new Notification.IndicatorStyle { SubText = body }; notification.AddStyle(style); NotificationManager.Post(notification); var time = notifyTime - DateTime.Now; int duration = (time.Seconds + time.Milliseconds / 1000); timer = new Timer(); timer.Interval = duration * 1000; timer.Elapsed += new ElapsedEventHandler(TimerElapsed); timer.Start(); }
public void CreateAlarm(List <Event> eventList) { AlarmManager.CancelAll(); foreach (Event e in eventList) { if (e.Start.DateTime == null) { continue; } Notification n = new Notification { Title = e.Summary, IsVisible = true }; n.Content = e.Start.DateTime.Value.ToString("yyyy.MM.dd HH:mm") + " - " + e.End.DateTime.Value.ToString("yyyy.MM.dd HH:mm"); Notification.ActiveStyle style = new Notification.ActiveStyle(); style.AddButtonAction(new Notification.ButtonAction { Index = 0, Text = "OK" }); n.AddStyle(style); AlarmManager.CreateAlarm(e.Start.DateTime.Value, n); } }
/// <summary> /// Show a local notification /// </summary> /// <param name="title">Title of the notification</param> /// <param name="body">Body or description of the notification</param> /// <param name="id">Id of the notification</param> public void Show(string title, string body, int id = 0) { Notification notification = new Notification { Title = title, Content = body, Tag = id.ToString(), }; Notification.IndicatorStyle style = new Notification.IndicatorStyle { SubText = body }; notification.AddStyle(style); NotificationManager.Post(notification); }
void PostNotification() { DirectoryInfo info = Tizen.Applications.Application.Current.DirectoryInfo; string iconPath; string bgPath; string sharedPath = info.SharedResource; string customViewNotiBody = "{" + "\"template\": \"standard\"," + "\"manifest_version\": 1," + "\"model_info\": \"tizen_public\"," + "\"category\": 3," + "\"paragraph\": [{" + "\"type\": \"image\"," + "\"content\": \"\"," + "\"thumbnail\": \"/opt/usr/globalapps/org.tizen.example.NotificaiontTest/shared/res/bg_square.jpg\"" + "}, {" + "\"type\": \"text\"," + "\"content\": \"<color=#62dd16ff font_size=70 font=Tizen:style=Bold>2000</color><br/><color=#62dd16ff font_size=28 font=Tizen:style=Regular>/2000 steps</color>\"" + "}, {" + "\"type\": \"text\"," + "\"content\": \"<color=#ffffffff font_size=30 font=Tizen:style=Regular>You've earned step rewards once this week!</color>\"" + "}]," + "\"always_wear\": 1" + "}"; iconPath = sharedPath + "NotificationTestServiceApp.png"; bgPath = sharedPath + "bg_square.jpg"; Notification noti = new Notification { Title = "COVID-19 TEST", Content = customViewNotiBody, Icon = iconPath }; Notification.AccessorySet accessory = new Notification.AccessorySet { SoundOption = AccessoryOption.On, CanVibrate = true }; noti.Accessory = accessory; Notification.ActiveStyle style = new Notification.ActiveStyle { IsAutoRemove = true, BackgroundImage = bgPath }; AppControl firstAppControl = new AppControl { ApplicationId = UiAppID }; Notification.ButtonAction button1 = new Notification.ButtonAction { Index = Tizen.Applications.Notifications.ButtonIndex.First, Text = "Launch UI App", Action = firstAppControl }; AppControl secondAppControl = new AppControl { ApplicationId = ServiceAppID }; secondAppControl.ExtraData.Add("op", "stop"); Notification.ButtonAction button2 = new Notification.ButtonAction { Index = Tizen.Applications.Notifications.ButtonIndex.Second, Text = "Stop Service Noti Loop", Action = secondAppControl }; style.AddButtonAction(button1); style.AddButtonAction(button2); noti.AddStyle(style); Log.Info("VCApp", "[VC] Post service........"); NotificationManager.Post(noti); }