/// <summary> /// Notifies the specified notification. /// </summary> /// <param name="notification">The notification.</param> public void Notify(LocalNotification notification) { if (notification.WindowsNotificationType == WPNotificationType.Tile) ShowTileNotification(notification); else if (notification.WindowsNotificationType == WPNotificationType.Toast) ShowToastNotification(notification); }
private string serializeNotification(LocalNotification notification) { var xmlSerializer = new XmlSerializer(notification.GetType()); using (var stringWriter = new StringWriter()) { xmlSerializer.Serialize(stringWriter, notification); return stringWriter.ToString(); } }
private Notification createNativeNotification(LocalNotification notification) { var builder = new Notification.Builder(Application.Context) .SetContentTitle(notification.Title) .SetContentText(notification.Text) // .SetSmallIcon(Resource.Drawable.IcDialogEmail); .SetSmallIcon(Application.Context.ApplicationInfo.Icon); var nativeNotification = builder.Build(); return nativeNotification; }
private UILocalNotification createNativeNotification(LocalNotification notification) { var nativeNotification = new UILocalNotification { AlertAction = notification.Title, AlertBody = notification.Text, FireDate = notification.NotifyTime, UserInfo = NSDictionary.FromObjectAndKey(NSObject.FromObject(notification.Id), NSObject.FromObject(NotificationKey)) }; return nativeNotification; }
/// <summary> /// Notifies the specified notification. /// </summary> /// <param name="notification">The notification.</param> public void Notify(LocalNotification notification) { var intent = createIntent(notification.Id); var serializedNotification = serializeNotification(notification); intent.PutExtra(ScheduledAlarmHandler.LocalNotificationKey, serializedNotification); var pendingIntent = PendingIntent.GetBroadcast(Application.Context, 0, intent, PendingIntentFlags.CancelCurrent); var triggerTime = notifyTimeInMilliseconds(notification.NotifyTime); var alarmManager = getAlarmManager(); alarmManager.Set(AlarmType.RtcWakeup, triggerTime, pendingIntent); }
private UILocalNotification createNativeNotification(LocalNotification notification) { var nativeNotification = new UILocalNotification { AlertAction = notification.Title, AlertBody = notification.Text, #if __UNIFIED__ FireDate = notification.NotifyTime.DateTimeToNSDate(), #else FireDate = notification.NotifyTime, #endif UserInfo = NSDictionary.FromObjectAndKey(NSObject.FromObject(notification.Id), NSObject.FromObject(NotificationKey)) }; return nativeNotification; }
/// <summary> /// Notifies the specified notification. /// </summary> /// <param name="notification">The notification.</param> public void Notify(LocalNotification notification) { var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text02); var tileTitle = tileXml.GetElementsByTagName("text"); ((XmlElement)tileTitle[0]).InnerText = notification.Title; ((XmlElement)tileTitle[1]).InnerText = notification.Text; var correctedTime = notification.NotifyTime <= DateTime.Now ? DateTime.Now.AddMilliseconds(100) : notification.NotifyTime; var scheduledTileNotification = new ScheduledTileNotification(tileXml, correctedTime) { Id = notification.Id.ToString() }; TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(scheduledTileNotification); }
private void ShowToastNotification(LocalNotification notification) { var tileXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); var tileTitle = tileXml.GetElementsByTagName("text"); ((XmlElement)tileTitle[0]).InnerText = notification.Title; ((XmlElement)tileTitle[1]).InnerText = notification.Text; var correctedTime = notification.NotifyTime <= DateTime.Now ? DateTime.Now.AddMilliseconds(100) : notification.NotifyTime; var scheduledToastNotification = new ScheduledToastNotification(tileXml, correctedTime) { Id = notification.Id.ToString() }; ToastNotificationManager.CreateToastNotifier().AddToSchedule(scheduledToastNotification); }
/// <summary> /// Notifies the specified notification. /// </summary> /// <param name="notification">The notification.</param> public void Notify(LocalNotification notification) { var nativeNotification = createNativeNotification(notification); UIApplication.SharedApplication.ScheduleLocalNotification(nativeNotification); }