예제 #1
0
 public async void RegisterNotificationHubs(string channel)
 {
     var connectionString = ConnectionString.CreateUsingSharedAccessKey(
         MobileServiceConfig.NotificationHubUri,
         MobileServiceConfig.NotificationHubKey,
         MobileServiceConfig.NotificationHubSecret);
     NotificationHub notificationHub = new NotificationHub(
         MobileServiceConfig.NotificationHubName, connectionString);
     await notificationHub.UnregisterAllAsync(channel);
     await notificationHub.RegisterTemplateAsync(channel, "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
     "<wp:Notification xmlns:wp=\"WPNotification\">" +
         "<wp:Toast>" +
             "<wp:Text1>" + "SlapChat" + "</wp:Text1>" +
             "<wp:Text2>" + "$(msg)" + "</wp:Text2>" +
         "</wp:Toast> " +
     "</wp:Notification>", "toast");
 }
        public void UnregisterFromAzurePushNotification()
        {
            var channel = HttpNotificationChannel.Find("MyPushChannel");
            if (channel == null)
            {
                channel = new HttpNotificationChannel("MyPushChannel");
                channel.Open();
                channel.BindToShellToast();
            }

            channel.ChannelUriUpdated += async (o, args) =>
            {
                var hub = new NotificationHub(PushNotificationCredentials.AzureNotificationHubName, PushNotificationCredentials.AzureListenConnectionString);

                await hub.UnregisterNativeAsync();
                await hub.UnregisterAllAsync(args.ChannelUri.ToString());
            };
        }
예제 #3
0
 private async void unregisterButton_Click(object sender, RoutedEventArgs e)
 {
        var channel = HttpNotificationChannel.Find(PUSH_CHANNEL_NAME);
         if (channel != null)
         {
             try
             {
                 var hub = new NotificationHub(PUSH_HUB_NAME, PUSH_HUB_CONNECTION);
                 await hub.UnregisterAllAsync(channel.ChannelUri.ToString());
             }
             catch (Exception ee) {
                 Debug.WriteLine("Unregistration failed!");
         
             }
         }
 }