Exemplo n.º 1
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            Notifier notifier = new Notifier();

            // It's important not to block UI threads. Since this is a background task, we do need
            // to block on the channel operations completing
            notifier.RenewAllAsync(false).AsTask().Wait();
        }
Exemplo n.º 2
0
        private async Task InitNotificationsAsync()
        {
            App.Channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

            var hub = new NotificationHub("notificationapp", "Endpoint=sb://KAIT-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=Qy+U8BBbQOpjUAX8v2FfhoNInn3CygnIfrjDh2F3xR4=");
            var result = await hub.RegisterNativeAsync(App.Channel.Uri,new string[] {"demo"});

            // Displays the registration ID so you know it was successful
            if (result.RegistrationId == null)
            {
                var dialog = new MessageDialog("Registration not successful: " + result.RegistrationId);
                dialog.Commands.Add(new UICommand("OK"));
                await dialog.ShowAsync();
            }
            else
            {
                Debug.WriteLine("Successful Notification Registration");
            }

            App.Notifier = new Notifier();


        }