当前位置: 首页>>代码示例>>C#>>正文


C# HttpNotificationChannel.BindToShellToast方法代码示例

本文整理汇总了C#中HttpNotificationChannel.BindToShellToast方法的典型用法代码示例。如果您正苦于以下问题:C# HttpNotificationChannel.BindToShellToast方法的具体用法?C# HttpNotificationChannel.BindToShellToast怎么用?C# HttpNotificationChannel.BindToShellToast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpNotificationChannel的用法示例。


在下文中一共展示了HttpNotificationChannel.BindToShellToast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AcquireToken

	    private async void AcquireToken()
	    {
	        var currentChannel = HttpNotificationChannel.Find(ChannelName);
		    if (currentChannel == null)
		    {
			    currentChannel = new HttpNotificationChannel(ChannelName);
				currentChannel.Open();
				currentChannel.BindToShellToast();
				currentChannel.ChannelUriUpdated += (sender, args) =>
				{
					RegisterToken(currentChannel.ChannelUri.AbsoluteUri);
				};

			    if (currentChannel.ChannelUri == null)
			    {
				    await Task.Delay(200);
					if(currentChannel.ChannelUri == null)
						return;
			    }

			    RegisterToken(currentChannel.ChannelUri.AbsoluteUri);
		    }
		    else
		    {
				currentChannel.ChannelUriUpdated += (sender, args) =>
				{
					RegisterToken(currentChannel.ChannelUri.AbsoluteUri);
				};
			}

			currentChannel.ShellToastNotificationReceived += OnNotificationReceived;
		}
开发者ID:QRyptoWire,项目名称:qrypto-wire,代码行数:32,代码来源:PhoneService.cs

示例2: AcquirePushChannel

        private void AcquirePushChannel()
        {
            CurrentChannel = HttpNotificationChannel.Find("MyPushChannel");

            if (CurrentChannel == null)
            {
                CurrentChannel = new HttpNotificationChannel("MyPushChannel");
                CurrentChannel.Open();
                CurrentChannel.BindToShellToast();
            }

            CurrentChannel.ChannelUriUpdated +=
                new EventHandler<NotificationChannelUriEventArgs>(async (o, args) =>
                {
                    MobileServiceClient client = todoItemManager.GetClient;

                    // Register for notifications using the new channel
                    const string template =
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?><wp:Notification " +
                    "xmlns:wp=\"WPNotification\"><wp:Toast><wp:Text1>$(message)</wp:Text1></wp:Toast></wp:Notification>";

                    await client.GetPush()
                        .RegisterTemplateAsync(CurrentChannel.ChannelUri.ToString(), template, "mytemplate");
                });
        }
开发者ID:fellipetenorio,项目名称:mobile-services-samples,代码行数:25,代码来源:App.xaml.cs

示例3: RegisterRawPushChannel

        public void RegisterRawPushChannel(string channelName = "RawPushChannel")
        {
            // Holds the push channel that is created or found.
            HttpNotificationChannel _rawPushChannel;

            // Try to find the push channel.
            _rawPushChannel = HttpNotificationChannel.Find(channelName);

            // If the channel was not found, then create a new connection to the push service.
            if (_rawPushChannel == null)
            {
                _rawPushChannel = new HttpNotificationChannel(channelName);

                // Register for all the events before attempting to open the channel.
                _rawPushChannel.ChannelUriUpdated += RawChannelUriUpdated;
                _rawPushChannel.ErrorOccurred += RawErrorOccurred;
                _rawPushChannel.HttpNotificationReceived += RawHttpNotificationReceived;

                _rawPushChannel.Open();

                // Bind this new channel for toast events.
                _rawPushChannel.BindToShellToast();

            }
            else
            {
                // The channel was already open, so just register for all the events.
                _rawPushChannel.ChannelUriUpdated += RawChannelUriUpdated;
                _rawPushChannel.ErrorOccurred += RawErrorOccurred;
                _rawPushChannel.HttpNotificationReceived += RawHttpNotificationReceived;

                // Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.

            }
        }
开发者ID:xepher,项目名称:uwp-wxbus,代码行数:35,代码来源:PushNotificationProvider.cs

示例4: ApplyTo

    internal void ApplyTo( HttpNotificationChannel httpNotificationChannel )
    {
      if( IsBindedToShellTile != null )
        if( IsBindedToShellTile.Value )
        {
          if( !httpNotificationChannel.IsShellTileBound )
            httpNotificationChannel.BindToShellTile();
        }
        else
        {
          if( httpNotificationChannel.IsShellTileBound )
            httpNotificationChannel.UnbindToShellTile();
        }

      if( IsBindedToShellToast != null )
        if( IsBindedToShellToast.Value )
        {
          if( !httpNotificationChannel.IsShellToastBound )
            httpNotificationChannel.BindToShellToast();
        }
        else
        {
          if( httpNotificationChannel.IsShellToastBound )
            httpNotificationChannel.UnbindToShellToast();
        }

      if( OnHttpNotificationReceived != null )
        httpNotificationChannel.HttpNotificationReceived += OnHttpNotificationReceived;

      if( OnShellToastNotificationReceived != null )
        httpNotificationChannel.ShellToastNotificationReceived += OnShellToastNotificationReceived;
    }
开发者ID:Georotzen,项目名称:.NET-SDK-1,代码行数:32,代码来源:PushNotificationsBinding.cs

示例5: PainelPage

        public PainelPage()
        {
            InitializeComponent();
            lblUsuario.Text = "@" + usuario.Nome;
            ListarGrupos();
            ListarUsuarios();

            // Iniciar canal
            HttpNotificationChannel pushChannel;
            string channelName = "MeNotaChannel";
            pushChannel = HttpNotificationChannel.Find(channelName);
            if (pushChannel == null)
            {
                pushChannel = new HttpNotificationChannel(channelName);
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
                pushChannel.Open();
                pushChannel.BindToShellToast();
            }
            else
            {
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
                (Application.Current as App).Usuario.Url = pushChannel.ChannelUri.ToString();
                AtualizarUsuario((Application.Current as App).Usuario);
            }
        }
开发者ID:felipemfp,项目名称:me-nota,代码行数:29,代码来源:PainelPage.xaml.cs

示例6: OnInit

        public override void OnInit()
        {
            configHandler.LoadAppPackageConfig();

            string channelName = "UAPush";

            // Try to find the push channel.
            pushChannel = HttpNotificationChannel.Find(channelName);

            // If the channel was not found, then create a new connection to the push service.
            if (pushChannel == null)
            {
                pushChannel = new HttpNotificationChannel(channelName);

                // Register for all the events before attempting to open the channel.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                pushChannel.Open();

                // Bind this new channel for toast events.
                pushChannel.BindToShellToast();
            }
            else
            {
                // The channel was already open, so just register for all the events.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                this.RegisterDevice(pushChannel.ChannelUri);
            }
        }
开发者ID:Endare,项目名称:phonegap-push-wp8,代码行数:32,代码来源:PushNotificationPlugin.cs

示例7: CreateNewChannel

 private HttpNotificationChannel CreateNewChannel()
 {
     var channel = HttpNotificationChannel.Find(AppContext.State.AppId);
     if (channel == null)
     {
         channel = new HttpNotificationChannel(AppContext.State.AppId);
         SubscribeToEvents(channel);
         // Open the channel
         channel.Open();
         UpdateChannelUri(channel.ChannelUri);
         // Register for tile notifications
         var whitelistedDomains = AppContext.State.Settings.PushSettings.WhitelistedDomains;
         if (whitelistedDomains.Count == 0)
             channel.BindToShellTile();
         else
             channel.BindToShellTile(new Collection<Uri>(whitelistedDomains));
         // Register for shell notifications
         channel.BindToShellToast();
     }
     else
     {
         SubscribeToEvents(channel);
         UpdateChannelUri(channel.ChannelUri);
     }
     return channel;
 }
开发者ID:appacitive,项目名称:appacitive-dotnet-sdk,代码行数:26,代码来源:SingletonPushChannel.cs

示例8: RegisterPushNotifications

        public void RegisterPushNotifications()
        {
            if (pushChannel != null) return;

            pushChannel = HttpNotificationChannel.Find(channelName);

            // If the channel was not found, then create a new connection to the push service.
            if (pushChannel == null) {
                pushChannel = new HttpNotificationChannel(channelName, "PositiveSSL CA");

                // Register for all the events before attempting to open the channel.
                pushChannel.ChannelUriUpdated += PushChannel_ChannelUriUpdated;
                pushChannel.ErrorOccurred += PushChannel_ErrorOccurred;
                pushChannel.HttpNotificationReceived += PushChannel_HttpNotificationReceived;

                pushChannel.Open();
                pushChannel.BindToShellToast();
                pushChannel.BindToShellTile();
            } else {
                // The channel was already open, so just register for all the events.
                pushChannel.ChannelUriUpdated += PushChannel_ChannelUriUpdated;
                pushChannel.ErrorOccurred += PushChannel_ErrorOccurred;
                pushChannel.HttpNotificationReceived += PushChannel_HttpNotificationReceived;
            }

            if (UriUpdated != null && pushChannel.ChannelUri != null) {
                UriUpdated(pushChannel.ChannelUri.ToString());
            }
        }
开发者ID:allanfreitas,项目名称:gtalkchat,代码行数:29,代码来源:PushHelper.cs

示例9: OpenChannel

        public void OpenChannel(Action<string> channelCallback)
        {
            try
            {
                _channel = HttpNotificationChannel.Find(ChannelName);
            }
            catch { }

            if (_channel != null && _channel.ChannelUri != null)
            {
                channelCallback(_channel.ChannelUri.ToString());
            }
            else
            {
                try
                {
                    _channel = new HttpNotificationChannel(ChannelName);
                    _channel.ChannelUriUpdated += (o, e) => channelCallback(e.ChannelUri.ToString());
                    _channel.Open();
                    _channel.BindToShellToast();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.ToString());
                }
            }
        }
开发者ID:chrisntr,项目名称:FlightsNorway,代码行数:27,代码来源:NotificationService.cs

示例10: MainPage

        // Constructor
        public MainPage()
        {
            HttpNotificationChannel pushChannel;
            String channelName = "ToastSampleChannel";
            InitializeComponent();
            pushChannel = HttpNotificationChannel.Find(channelName);
            if (pushChannel == null)
            {
                pushChannel = new HttpNotificationChannel(channelName);
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
                pushChannel.Open();
                pushChannel.BindToShellToast();
            }
            else
            {
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
                System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
                MessageBox.Show(String.Format("Channel uri is {0}", pushChannel.ChannelUri.ToString()));
            }

        }
开发者ID:sangnvus,项目名称:2015FALLIS01,代码行数:26,代码来源:MainPage.xaml.cs

示例11: CreatingANotificationChannel

        public void CreatingANotificationChannel()
        {
            // 既存のチャンネルを探す
            myChannel = HttpNotificationChannel.Find(ChannelName);

            if (myChannel == null)
            {
                // チャンネルがなければ作成する
                myChannel = new HttpNotificationChannel(ChannelName);
                SetUpDelegates();

                // Openすると、ChannelUriUpdated が発行される
                myChannel.Open();

                myChannel.BindToShellToast();
            }
            else
            {
                SetUpDelegates();
            }

            // サービスを登録する
            if (myChannel.ChannelUri != null)
            {
                RegistToService(myChannel.ChannelUri.ToString());
            }
        }
开发者ID:iseebi,项目名称:wp7push_ethna,代码行数:27,代码来源:MainPage.xaml.cs

示例12: MainPage

        // Constructor
        public MainPage()
        {
            InitializeComponent();

            DataContext = App.ViewModel;

            // Try to find the push channel.
            pushChannel = HttpNotificationChannel.Find(channelName);

            // If the channel was not found, then create a new connection to the push service.
            if (pushChannel == null)
            {
                pushChannel = new HttpNotificationChannel(channelName);

                // Register for all the events before attempting to open the channel.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                // Register for this notification only if you need to receive the notifications while your application is running.
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);

                pushChannel.Open();


                // Bind this new channel for toast events.
                pushChannel.BindToShellToast();

            }
            else
            {
                // The channel was already open, so just register for all the events.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                // Register for this notification only if you need to receive the notifications while your application is running.
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);

                // Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
                //System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
                //MessageBox.Show(String.Format("Channel Uri is {0}", pushChannel.ChannelUri.ToString()));
            }


            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();

            httpClient = new HttpClient();

            // Add a user-agent header
            var headers = httpClient.DefaultRequestHeaders;

            // HttpProductInfoHeaderValueCollection is a collection of 
            // HttpProductInfoHeaderValue items used for the user-agent header

            headers.UserAgent.ParseAdd("ie");
            headers.UserAgent.ParseAdd("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");

        }
开发者ID:MartinaAkello,项目名称:UCCFieldApplication,代码行数:59,代码来源:MainPage.xaml.cs

示例13: MainPage

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            //Create soap client for the GovBids service
            client = new AvailBidsSoapClient();

            //Connect the Get Bids Completed event (Async)
            client.GetBidsCompleted += client_GetBidsCompleted;

            var progressIndicator = new ProgressIndicator();
            SystemTray.SetProgressIndicator(this, progressIndicator);

            /// Holds the push channel that is created or found.
            HttpNotificationChannel pushChannel;

            // The name of our push channel.
            string channelName = "ToastUpdateChannel";

            InitializeComponent();

            // Try to find the push channel.
            pushChannel = HttpNotificationChannel.Find(channelName);

            // If the channel was not found, then create a new connection to the push service.
            if (pushChannel == null)
            {
                pushChannel = new HttpNotificationChannel(channelName);

                // Register for all the events before attempting to open the channel.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                // Register for this notification only if you need to receive the notifications while your application is running.
                //pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);

                pushChannel.Open();

                // Bind this new channel for toast events.
                pushChannel.BindToShellToast();

            }
            else
            {
                // The channel was already open, so just register for all the events.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                // Register for this notification only if you need to receive the notifications while your application is running.
                //pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);

                // Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
                System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
                //MessageBox.Show(String.Format("Channel Uri is {0}",
                  //  pushChannel.ChannelUri.ToString()));

            }
        }
开发者ID:giangonz,项目名称:GovBids,代码行数:58,代码来源:MainPage.xaml.cs

示例14: XPushNotificationHelper

        public XPushNotificationHelper()
        {
            /// Holds the push channel that is created or found.
            HttpNotificationChannel pushChannel;

            // The name of our push channel.
            string channelName = XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("ProductID").Value;

            // Try to find the push channel.
            pushChannel = HttpNotificationChannel.Find(channelName);

            // If the channel was not found, then create a new connection to the push service.
            if (pushChannel == null)
            {
                pushChannel = new HttpNotificationChannel(channelName);

                // Register for all the events before attempting to open the channel.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                // Register for this notification only if you need to receive the notifications while your application is running.
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
                pushChannel.HttpNotificationReceived += new EventHandler<HttpNotificationEventArgs>(PushChannel_HttpNotificationReceived);
                pushChannel.Open();

                //Raw push only work on app running

                // Bind this new channel for toast events.
                //Toast push is work app is running or background!
                pushChannel.BindToShellToast();
                // Bind this new channel for tile events.
                //Tile push is work background or died!
                pushChannel.BindToShellTile();

            }
            else
            {
                // The channel was already open, so just register for all the events.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                // Register for this notification only if you need to receive the notifications while your application is running.
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
                pushChannel.HttpNotificationReceived += new EventHandler<HttpNotificationEventArgs>(PushChannel_HttpNotificationReceived);

                if (null == pushChannel.ChannelUri)
                    return;

                // Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
                XLog.WriteInfo("push channel URI is : " + pushChannel.ChannelUri.ToString());
                //保存 Uri,由push扩展获取发送到js端
                IsolatedStorageSettings userSettings = IsolatedStorageSettings.ApplicationSettings;
                userSettings[XConstant.PUSH_NOTIFICATION_URI] = pushChannel.ChannelUri.ToString();
                userSettings.Save();
            }
        }
开发者ID:polyvi,项目名称:xface-extension-push,代码行数:56,代码来源:XPushNotificationHelper.cs

示例15: Register

		public static HttpNotificationChannel Register(string channelName, 
			Collection<Uri> baseUris, bool bindToShellTile, bool bindToShellToast, 
			EventHandler<NotificationChannelErrorEventArgs> errorHandler, 
			Action<HttpNotificationChannel, bool> completed)
		{
			try
			{
				var channel = HttpNotificationChannel.Find(channelName);
				if (channel == null)
				{
					channel = new HttpNotificationChannel(channelName);
					channel.ChannelUriUpdated += (s, e) =>
					{
						if (!channel.IsShellTileBound && bindToShellTile)
						{
							if (baseUris != null)
								channel.BindToShellTile(baseUris);
							else
								channel.BindToShellTile();
						}

						if (!channel.IsShellToastBound && bindToShellToast)
							channel.BindToShellToast();

						completed(channel, true);
					};
					channel.ErrorOccurred += (sender, args) => completed(null, false);

					if (errorHandler != null)
						channel.ErrorOccurred += errorHandler;

					channel.Open();
				}
				else
				{
					if (errorHandler != null)
					{
						channel.ErrorOccurred -= errorHandler;
						channel.ErrorOccurred += errorHandler;
					}

					completed(channel, false);
				}
				return channel;
			}
			catch (Exception ex)
			{
				if (Debugger.IsAttached)
					Debugger.Break();

				completed(null, false);
				return null; 
			}
		}
开发者ID:RareNCool,项目名称:MyToolkit,代码行数:54,代码来源:PushNotifications.cs


注:本文中的HttpNotificationChannel.BindToShellToast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。