本文整理汇总了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;
}
示例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");
});
}
示例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.
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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());
}
}
示例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());
}
}
}
示例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()));
}
}
示例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());
}
}
示例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)");
}
示例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()));
}
}
示例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();
}
}
示例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;
}
}