Пример #1
0
        private void SendBadge_Click(object sender, RoutedEventArgs e)
        {
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
            rootPage.NotifyUser("Badge notification sent", NotifyType.StatusMessage);
        }
Пример #2
0
        // Initialize the app's tiles on the Start page. There are three different sizes of tiles users can
        // choose from.
        private void InitializeTiles()
        {
            tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            var mediumSquareTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText01);
            var largeSquareTile  = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare310x310ImageAndText02);
            var wideTile         = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage02);

            tileUpdater.EnableNotificationQueue(true);

            mediumSquareTile.GetElementsByTagName("text")[0].InnerText = "TicTacToe";
            largeSquareTile.GetElementsByTagName("text")[0].InnerText  = "TicTacToe";
            wideTile.GetElementsByTagName("text")[0].InnerText         = "TicTacToe";

            var node1 = wideTile.ImportNode(mediumSquareTile.GetElementsByTagName("binding")[0], true);

            wideTile.GetElementsByTagName("visual")[0].AppendChild(node1);

            var node2 = wideTile.ImportNode(largeSquareTile.GetElementsByTagName("binding")[0], true);

            wideTile.GetElementsByTagName("visual")[0].AppendChild(node2);

            var testNotification = new TileNotification(wideTile);

            testNotification.Tag = "Test";
            tileUpdater.Update(testNotification);

            badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
        }
Пример #3
0
        private void BuildNotifications(IList <Notifications> notifications)
        {
            List <Notifications> filteredNotifications = notifications.Where(n => !n.content.StartsWith("You")).ToList();
            var badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            badgeUpdater.Clear();
            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.EnableNotificationQueue(true);
            tileUpdater.Clear();
            BadgeNumericContent badgeContent = new BadgeNumericContent((uint)filteredNotifications.Count);

            badgeUpdater.Update(new BadgeNotification(badgeContent.GetXml()));
            ToastNotificationManager.ConfigureNotificationMirroring(NotificationMirroring.Allowed);

            // Keep track of the number feed items that get tile notifications.
            int itemCount = 0;

            // Create a tile notification for each feed item.
            foreach (var notification in filteredNotifications)
            {
                // Create a new tile notification.
                tileUpdater.Update(new TileNotification(GenerateTileContent(notification).GetXml()));
                ToastNotification toastNotification = new ToastNotification(GenerateToastContent(notification).GetXml());
                ToastNotificationManager.CreateToastNotifier().Show(toastNotification);
                // Don't create more than 5 notifications.
                if (itemCount++ > 5)
                {
                    break;
                }
            }
        }
Пример #4
0
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public static void IncBadgeCount()
        {
            // Get the blank badge XML payload for a badge number
            XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            // Set the value of the badge in the XML to our number
            XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;
            string     value        = null;

            try
            {
                value = badgeElement.GetAttribute("value");
            }
            catch (Exception) { Logger.Debug("Failed to retrieve badge count value node."); }

            if (int.TryParse(value, out int count))
            {
                badgeElement.SetAttribute("value", (count + 1).ToString());
            }
            else
            {
                badgeElement.SetAttribute("value", "1");
            }

            // Create the badge notification
            BadgeNotification badge = new BadgeNotification(badgeXml);

            // Create the badge updater for the application
            BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            // And update the badge
            badgeUpdater.Update(badge);
        }
Пример #5
0
        private async void BadgeToggleSwitch_Toggled(object sender, RoutedEventArgs e)
        {
            if (Badge.IsOn)
            {
                badgeTile = new SecondaryTile(
                    "BadgeTile",
                    "Badge",
                    "Arguments",
                    new Uri("ms-appx:///Assets/green.150x150.png", UriKind.Absolute),
                    TileSize.Square150x150);
                await badgeTile.RequestCreateAsync();

                tileXml   = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);
                tileImage = tileXml.SelectSingleNode("/badge") as XmlElement;
                tileImage.SetAttribute("value", "alert");

                BadgeNotification badgeNotification = new BadgeNotification(tileXml);
                BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(badgeTile.TileId).Update(badgeNotification);

                tileXml   = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
                tileImage = tileXml.SelectSingleNode("/badge") as XmlElement;
                tileImage.SetAttribute("value", "31");
                badgeNotification = new BadgeNotification(tileXml);
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeNotification);
            }
            else
            {
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
                await badgeTile.RequestDeleteAsync();
            }
        }
Пример #6
0
        public static void SendBadge(uint count)
        {
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(count);
            BadgeNotification notif = new BadgeNotification(badgeContent.GetXml());

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(notif);
        }
Пример #7
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            // Enable the tile queue on the primary tile (enables medium/wide/large tile queues)
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            var shell = await Initialize();

            // Place our app shell in the current Window
            Window.Current.Content = shell;

            if (shell.AppFrame.Content == null)
            {
                var facade = ServiceLocator.Current.GetInstance <INavigationFacade>();

                if (AppLaunchCounter.IsFirstLaunch())
                {
                    facade.NavigateToWelcomeView();
                }
                else
                {
                    facade.NavigateToCategoriesView();
                }
            }

            // Refresh launch counter, needs to be done
            // after AppLaunchCounter.IsFirstLaunch() is being checked.
            AppLaunchCounter.RegisterLaunch();

            // Ensure the current window is active
            Window.Current.Activate();
        }
Пример #8
0
        /// <summary>
        /// 更新磁贴图标
        /// </summary>
        /// <param name="number"></param>
        public static void UpdateBadgeWithGlyph(int index)
        {
            BadgeGlyphNotificationContent badgeContent = new BadgeGlyphNotificationContent((GlyphValue)index);

            // Send the notification to the application’s tile.
            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
        }
Пример #9
0
        public static void UpdateTile(int value)
        {
            var type     = BadgeTemplateType.BadgeNumber;
            var xml      = BadgeUpdateManager.GetTemplateContent(type);
            var elements = xml.GetElementsByTagName("badge");
            var element  = elements[0] as XmlElement;

            element.SetAttribute("value", value.ToString());

            var updater      = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
            var notification = new BadgeNotification(xml);

            updater.Update(notification);

            Debug.WriteLine("Background task badge updated: " + value.ToString());

            var template = ToastTemplateType.ToastText01;

            xml = ToastNotificationManager.GetTemplateContent(template);
            var text = xml.CreateTextNode(string.Format("Badge updated to {0}", value));

            elements = xml.GetElementsByTagName("text");
            elements[0].AppendChild(text);

            var toast    = new ToastNotification(xml);
            var notifier = ToastNotificationManager.CreateToastNotifier();

            notifier.Show(toast);

            Debug.WriteLine("Background task toast shown: " + value.ToString());
        }
Пример #10
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            if (CurrentShoppingCart == null)
            {
                return;
            }

            var badgeContent =
                new BadgeNumericNotificationContent((uint)CurrentShoppingCart.ItemsQuantity);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication()
            .Update(badgeContent.CreateNotification());

            if (CurrentShoppingCart.Items.Count > 0)
            {
                _tileSquareContent.TextBodyWrap.Text =
                    string.Format(SHOPPING_CART_MESSAGE, CurrentShoppingCart.ItemsQuantity);

                _tileWideContent.TextHeadingWrap.Text =
                    string.Format(SHOPPING_CART_MESSAGE, CurrentShoppingCart.ItemsQuantity);
            }
            else
            {
                _tileSquareContent.TextBodyWrap.Text  = EMPTY_SHOPPING_CART_MESSAGE;
                _tileWideContent.TextHeadingWrap.Text = EMPTY_SHOPPING_CART_MESSAGE;
            }

            _tileWideContent.Square150x150Content = _tileSquareContent;

            TileUpdateManager.CreateTileUpdaterForApplication()
            .Update(_tileWideContent.CreateNotification());
        }
Пример #11
0
        private static void UpdateBadgeGlyph(string badgeGlyphValue)
        {
            //https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-badges

            if (badgeGlyphValue.IsNullOrWhiteSpace())
            {
                badgeGlyphValue = "alert";
            }

            // Get the blank badge XML payload for a badge glyph
            XmlDocument badgeXml =
                BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);

            // Set the value of the badge in the XML to our glyph value
            XmlElement badgeElement =
                badgeXml.SelectSingleNode("/badge") as XmlElement;

            badgeElement.SetAttribute("value", badgeGlyphValue);

            // Create the badge notification
            BadgeNotification badge = new BadgeNotification(badgeXml);

            // Create the badge updater for the application
            BadgeUpdater badgeUpdater =
                BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            // And update the badge
            badgeUpdater.Update(badge);
        }
Пример #12
0
 private void UpdateBadge(bool playing, bool paused)
 {
     try
     {
         string xmlstring;
         if (playing && !paused)
         {
             xmlstring = "<badge value=\"playing\"/>";
         }
         else
         if (paused)
         {
             xmlstring = "<badge value=\"paused\"/>";
         }
         else
         {
             xmlstring = "<badge value=\"stopped\"/>";
         }
         XmlDocument xdoc = new XmlDocument();
         xdoc.LoadXml(xmlstring);
         BadgeNotification bnotification = new BadgeNotification(xdoc);
         BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(bnotification);
     }
     catch (Exception ex)
     {
         NotifyUser(ex);
     }
 }
Пример #13
0
        private void OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
        {
            switch (args.NotificationType)
            {
            case PushNotificationType.Badge:     // badge 通知
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(args.BadgeNotification);
                break;

            case PushNotificationType.Raw:     // raw 通知
                // 当收到推送的 raw 通知时,如果 app 在锁屏,则可以触发后台任务以执行相关的逻辑(PushNotificationTrigger)
                string msg = args.RawNotification.Content;
                break;

            case PushNotificationType.Tile:     // tile 通知
                TileUpdateManager.CreateTileUpdaterForApplication().Update(args.TileNotification);
                break;

            case PushNotificationType.Toast:     // toast 通知
                ToastNotificationManager.CreateToastNotifier().Show(args.ToastNotification);
                break;

            default:
                break;
            }
        }
Пример #14
0
        public static void UpdateBadgeGlyph(BadgeGlyph glyph)
        {
            // Create the badge updater for the application
            BadgeUpdater updater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            if (glyph == BadgeGlyph.None)
            {
                updater.Clear();
            }
            else
            {
                // Get the blank badge XML payload for a badge number
                XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);

                // Set the value of the badge in the xml to our number
                XmlElement badgeElem = badgeXml.SelectSingleNode("/badge") as XmlElement;
                badgeElem.SetAttribute("value", glyph.DescriptionAttr());

                // Create the badge notification
                BadgeNotification badge = new BadgeNotification(badgeXml)
                {
                    ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10)
                };
                // And update the badge
                updater.Update(badge);
            }
        }
Пример #15
0
        private void SetState(StateType state)
        {
            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
            string badgeGlyphValue = "";

            switch (state)
            {
            case StateType.available:
                badgeGlyphValue = "available";
                break;

            case StateType.away:
                badgeGlyphValue = "away";
                break;

            case StateType.busy:
                badgeGlyphValue = "busy";
                break;

            default:
                break;
            }
            XmlDocument badgeXml     = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);
            XmlElement  badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;

            badgeElement.SetAttribute("value", badgeGlyphValue);
            BadgeNotification badge        = new BadgeNotification(badgeXml);
            BadgeUpdater      badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            badgeUpdater.Update(badge);
        }
Пример #16
0
        private static void UpdateBadge(int badgeNumber)
        {
#if WNS_PUSH_SERVICE
            var badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication("xcee0f789y8059y4881y8883y347265c01f93x");
            if (badgeNumber == 0)
            {
                badgeUpdater.Clear();
                return;
            }

            var badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            var badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");
            badgeElement.SetAttribute("value", badgeNumber.ToString());

            try
            {
                badgeUpdater.Update(new BadgeNotification(badgeXml));
            }
            catch (Exception ex)
            {
                Telegram.Logs.Log.Write(ex.ToString());
            }
#endif
        }
Пример #17
0
        /// <summary>
        /// 更新磁贴数字
        /// </summary>
        /// <param name="number"></param>
        public static void UpdateBadgeWithNumber(int number)
        {
            BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number);

            // Send the notification to the application’s tile.
            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
        }
Пример #18
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferal = taskInstance.GetDeferral();

            if (taskInstance.TriggerDetails is RawNotification)
            {
                var details   = taskInstance.TriggerDetails as RawNotification;
                var arguments = details.Content.Split(':');

                if (arguments.Count() > 0)
                {
                    switch (arguments[0])
                    {
                    case "new_items":
                        if (arguments.Count() > 1)
                        {
                            XmlDocument badgeXml     = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
                            XmlElement  badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");
                            badgeElement.SetAttribute("value", arguments[1]);
                            BadgeNotification badge = new BadgeNotification(badgeXml);
                            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
                        }
                        break;
                    }
                }
            }



            deferal.Complete();
        }
Пример #19
0
        private void pushChannel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
        {
            switch (args.NotificationType)
            {
            case PushNotificationType.Badge:     // badge Notify
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(args.BadgeNotification);
                break;

            case PushNotificationType.Raw:     // raw Notify
                string msg = args.RawNotification.Content;
                break;

            case PushNotificationType.Tile:     // tile Notify
                TileUpdateManager.CreateTileUpdaterForApplication().Update(args.TileNotification);
                break;

            case PushNotificationType.Toast:     // toast Notify
                ToastNotificationManager.CreateToastNotifier().Show(args.ToastNotification);
                break;

            default:
                break;
            }
            args.Cancel = true;
        }
        private async void ButtonUpdateBadgeNumber_Click(object sender, RoutedEventArgs e)
        {
            int num;

            if (!int.TryParse(TextBoxNumber.Text, out num))
            {
                await new MessageDialog("You must provide a valid integer.", "Error").ShowAsync();
                return;
            }

            // Get the blank badge XML payload for a badge number
            XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            // Set the value of the badge in the XML to our number
            XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;

            badgeElement.SetAttribute("value", num.ToString());

            // Create the badge notification
            BadgeNotification badge = new BadgeNotification(badgeXml);

            // Create the badge updater for the application
            BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            // And update the badge
            badgeUpdater.Update(badge);
        }
Пример #21
0
        /// <summary>
        /// 更新未读头条文章的徽章badge
        /// </summary>
        /// <param name="t"></param>
        private static void UpdateBadge(LatestStories t)
        {
            //将当天未读TOP文章更新到 badge
            int un_readed = 0;

            t.Top_Stories.ToList().ForEach(s => { if (!DataShareManager.Current.ReadedList.Contains(s.ID))
                                                  {
                                                      un_readed++;
                                                  }
                                           });

            var updater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            if (un_readed != 0)
            {
                var badgexml = new BadgeNumericNotificationContent((uint)un_readed);

                var n = badgexml.CreateNotification();
                n.ExpirationTime = DateTime.Now.AddDays(7);

                updater.Update(n);
            }
            else
            {
                updater.Clear();
            }
        }
Пример #22
0
        //Set tile to failed update
        XmlDocument RenderTileLiveFailed(string TileId)
        {
            try
            {
                Debug.WriteLine("Set tile to failed: " + TileId);

                //Reset primary tile
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
                TileUpdateManager.CreateTileUpdaterForApplication().Clear();

                Tile_UpdateManager  = TileUpdateManager.CreateTileUpdaterForSecondaryTile(TileId);
                Tile_PlannedUpdates = Tile_UpdateManager.GetScheduledTileNotifications();

                foreach (ScheduledTileNotification Tile_Update in Tile_PlannedUpdates)
                {
                    try { Tile_UpdateManager.RemoveFromSchedule(Tile_Update); } catch { }
                }
                BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(TileId).Clear();

                Tile_XmlContent.LoadXml("<tile><visual branding=\"none\"><binding template=\"TileSquareImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/SquareLogoFailed.png\"/></binding><binding template=\"TileWideImage\"><image id=\"1\" src=\"ms-appx:///Assets/Tiles/WideLogoFailed.png\"/></binding></visual></tile>");
                Tile_UpdateManager.Update(new TileNotification(Tile_XmlContent));
            }
            catch { }
            return(Tile_XmlContent);
        }
        void UpdateBadgeWithGlyphWithStringManipulation()
        {
            // Create a string with the badge template xml.
            string badgeXmlString = "<badge value='" + ((TileGlyph)GlyphList.SelectedItem).Name.ToString() + "'/>";

            Windows.Data.Xml.Dom.XmlDocument badgeDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                // Create a DOM.
                badgeDOM.LoadXml(badgeXmlString);

                // Load the xml string into the DOM, catching any invalid xml characters.
                BadgeNotification badge = new BadgeNotification(badgeDOM);

                // Create a badge notification and send it to the application’s tile.
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);

                OutputTextBlock.Text = badgeDOM.GetXml();
                rootPage.NotifyUser("Badge sent", NotifyType.StatusMessage);
            }
            catch (Exception)
            {
                OutputTextBlock.Text = string.Empty;
                rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage);
            }
        }
Пример #24
0
        static public void UpdateWatchedBadge(WhirlMonData.WhirlPoolAPIData.RootObject data)
        {
            try
            {
                int unread = data.totalUnread;

                if (unread == 0)
                {
                    BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
                }
                else
                {
                    XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

                    XmlElement badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");
                    badgeElement.SetAttribute("value", unread.ToString());

                    BadgeNotification badge = new BadgeNotification(badgeXml);
                    BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
                }
            }
            catch (Exception x)
            {
                ShowErrorToast("UpdateWatchedBadge", x);
            }
        }
Пример #25
0
        private static void UpdateBadge(int badgeNumber)
        {
            var badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            if (badgeNumber == 0)
            {
                badgeUpdater.Clear();
                return;
            }

            var badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            var badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");

            badgeElement.SetAttribute("value", badgeNumber.ToString());

            try
            {
                badgeUpdater.Update(new BadgeNotification(badgeXml));
            }
            catch (Exception ex)
            {
                Telegram.Logs.Log.Write(ex.ToString());
            }
        }
Пример #26
0
        public static void UpdateMainTile()
        {
#if WNS_PUSH_SERVICE
            try
            {
                ToastNotificationManager.History.Clear();
            }
            catch (Exception ex)
            {
                Telegram.Logs.Log.Write("ClearNotifications ex " + ex);
                Execute.ShowDebugMessage("Clear notifications history exception\n" + ex);
            }

            try
            {
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
                TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            }
            catch (Exception ex)
            {
                Telegram.Logs.Log.Write("ClearTile ex " + ex);
                Execute.ShowDebugMessage("Clear tile exception\n" + ex);
            }
#else
            // no way to clear toast history with MPNS
            //try
            //{
            //    ToastNotificationManager.History.Clear();
            //}
            //catch (Exception ex)
            //{
            //    Telegram.Logs.Log.Write("ClearNotifications ex " + ex);
            //    Execute.ShowDebugMessage("Clear notifications history exception\n" + ex);
            //}

            var tile = ShellTile.ActiveTiles.FirstOrDefault();
            if (tile == null)
            {
                return;
            }

#if WP8
            var tileData = new IconicTileData {
                Count = 0, WideContent1 = "", WideContent2 = "", WideContent3 = ""
            };
#else
            var tileData = new StandardTileData {
                Count = 0
            };
#endif
            try
            {
                tile.Update(tileData);
            }
            catch (Exception ex)
            {
                Execute.ShowDebugMessage("Tile.Update exception\n" + ex);
            }
#endif
        }
Пример #27
0
        private async void OnStartSync()
        {
            //#if DEBUG
            await VoIPConnection.Current.ConnectAsync();

            //#endif

            await Toast.RegisterBackgroundTasks();

            BadgeUpdateManager.CreateBadgeUpdaterForApplication("App").Clear();
            TileUpdateManager.CreateTileUpdaterForApplication("App").Clear();
            ToastNotificationManager.History.Clear("App");

#if !DEBUG && !PREVIEW
            Execute.BeginOnThreadPool(async() =>
            {
                await new AppUpdateService().CheckForUpdatesAsync();
            });
#endif

            //if (ApiInformation.IsTypePresent("Windows.ApplicationModel.FullTrustProcessLauncher"))
            //{
            //    await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
            //}

            try
            {
                // Prepare stuff for Cortana
                var localVoiceCommands = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///VoiceCommands/VoiceCommands.xml"));

                await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(localVoiceCommands);
            }
            catch { }
        }
Пример #28
0
        /// <summary>
        /// Clears the badge.
        /// </summary>
        public void ClearBadge()
        {
#if WINDOWS_PHONE
            SetBadgeWP8(0);
#else
            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
#endif
        }
        public NotificationsImpl()
        {
            this.badgeUpdater  = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
            this.toastNotifier = ToastNotificationManager.CreateToastNotifier();

            this.badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            this.badgeEl  = (XmlElement)this.badgeXml.SelectSingleNode("/badge");
        }
 /// <summary>
 /// Initialises a new instance of the Skycap.Notifications.EmailBadgeNotification class.
 /// </summary>
 static EmailBadgeNotification()
 {
     // Initialise local variables
     if (_badgeUpdater == null)
     {
         _badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
     }
 }