本文整理汇总了C#中HttpNotificationChannel类的典型用法代码示例。如果您正苦于以下问题:C# HttpNotificationChannel类的具体用法?C# HttpNotificationChannel怎么用?C# HttpNotificationChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpNotificationChannel类属于命名空间,在下文中一共展示了HttpNotificationChannel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: open_Click
private void open_Click(object sender, RoutedEventArgs e)
{
var channel = HttpNotificationChannel.Find("TestChannel");
if (channel == null || channel.ChannelUri == null)
{
if(channel != null)
{
channel.Close();
channel.Dispose();
}
channel = new HttpNotificationChannel("TestChannel");
channel.ChannelUriUpdated += channel_ChannelUriUpdated;
channel.ErrorOccurred += channel_ErrorOccurred;
channel.Open();
}
else
{
channel.ErrorOccurred += channel_ErrorOccurred;
Debug.WriteLine(channel.ChannelUri.AbsoluteUri);
}
channel.ShellToastNotificationReceived += channel_ShellToastNotificationReceived;
if(!channel.IsShellToastBound) channel.BindToShellToast();
}
开发者ID:follesoe,项目名称:WP7Demos,代码行数:27,代码来源:PushNotification.xaml.cs
示例3: 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
示例4: EnableNotifications
public static void EnableNotifications(string username)
{
_username = username;
if (_channel != null)
return;
_channel = HttpNotificationChannel.Find(CHANNEL);
if (_channel == null)
{
_channel = new HttpNotificationChannel(CHANNEL);
WireChannel(_channel);
_channel.Open();
}
else
WireChannel(_channel);
if (!_channel.IsShellToastBound)
_channel.BindToShellToast();
if (_channel.ChannelUri != null)
{
var ns = new NotificationServiceClient();
ns.RegisterEndpointAsync(username, _channel.ChannelUri.ToString());
}
}
开发者ID:SamirHafez,项目名称:Bantu,代码行数:26,代码来源:Manager.cs
示例5: RegisterTilePushChannel
public void RegisterTilePushChannel(string channelName = "TilePushChannel")
{
// Holds the push channel that is created or found.
HttpNotificationChannel _tilePushChannel;
// Try to find the push channel.
_tilePushChannel = HttpNotificationChannel.Find(channelName);
// If the channel was not found, then create a new connection to the push service.
if (_tilePushChannel == null)
{
_tilePushChannel = new HttpNotificationChannel(channelName);
// Register for all the events before attempting to open the channel.
_tilePushChannel.ChannelUriUpdated += TileChannelUriUpdated;
_tilePushChannel.ErrorOccurred += TileErrorOccurred;
_tilePushChannel.Open();
// Bind this new channel for toast events.
_tilePushChannel.BindToShellToast();
}
else
{
// The channel was already open, so just register for all the events.
_tilePushChannel.ChannelUriUpdated += TileChannelUriUpdated;
_tilePushChannel.ErrorOccurred += TileErrorOccurred;
// Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
}
}
开发者ID:xepher,项目名称:uwp-wxbus,代码行数:33,代码来源:PushNotificationProvider.cs
示例6: 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
示例7: register
public void register(string options)
{
try
{
var args = JSON.JsonHelper.Deserialize<string[]>(options);
var pushOptions = JSON.JsonHelper.Deserialize<Options>(args[0]);
this.channelName = pushOptions.ChannelName;
this.toastCallback = pushOptions.NotificationCallback;
}
catch (Exception)
{
this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
return;
}
this.pushChannel = HttpNotificationChannel.Find(this.channelName);
if (this.pushChannel == null)
{
this.pushChannel = new HttpNotificationChannel(this.channelName);
this.PushChannel_HookEvents();
this.pushChannel.Open();
this.pushChannel.BindToShellToast();
this.pushChannel.BindToShellTile();
}
else
{
this.PushChannel_HookEvents();
var result = new RegisterResult();
result.ChannelName = this.channelName;
result.Uri = this.pushChannel.ChannelUri.ToString();
this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, result));
}
}
开发者ID:nadyaA,项目名称:PushPlugin,代码行数:34,代码来源:PushPlugin.cs
示例8: RegisterDevice
public void RegisterDevice(object state)
{
IsRegistering = true;
HttpNotificationChannel pushChannel;
pushChannel = HttpNotificationChannel.Find("RegistrationChannel");
if (pushChannel == null)
{
pushChannel = new HttpNotificationChannel("RegistrationChannel");
}
RegistrationRequest req = new RegistrationRequest()
{
ChannelUri = pushChannel.ChannelUri.ToString(),
DeviceType = (short)Common.Data.DeviceType.WindowsPhone7
};
string json = null;
using (MemoryStream ms = new MemoryStream())
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(RegistrationRequest));
serializer.WriteObject(ms, req);
json = Encoding.UTF8.GetString(ms.ToArray(), 0, (int)ms.Length);
}
WebClient registrationClient = new WebClient();
registrationClient.Headers["content-type"] = "application/json";
registrationClient.UploadStringCompleted += registrationClient_UploadStringCompleted;
string url = string.Format("http://{0}/Services/RegisterDevice", App.ServiceHostName);
registrationClient.UploadStringAsync(new Uri(url), json);
}
开发者ID:tomasmcguinness,项目名称:AzureManager,代码行数:33,代码来源:AddSubscriptionViewModel.cs
示例9: DoConnect
private void DoConnect()
{
try
{
//首先查看现有的频道
httpChannel = HttpNotificationChannel.Find(channelName);
//如果频道存在
if (httpChannel != null)
{
//注册Microsoft推送通知事件
SubscribeToChannelEvents();
//检测Microsoft通知服务注册状态
SubscribeToService();
//订阅Toast和Title通知
SubscribeToNotifications();
}
else
{
//试图创建一个新的频道
//创建频道
httpChannel = new HttpNotificationChannel(channelName, "PuzzleService");
//推送通知频道创建成功
SubscribeToChannelEvents();
//注册Microsoft推送通知事件
httpChannel.Open();
}
}
catch (Exception ex)
{
//创建或恢复频道时发生异常
}
}
开发者ID:cityjoy,项目名称:CommonToolkit,代码行数:32,代码来源:PushMsg.cs
示例10: CreatePushChannel
// LIVE TILE CODE ADDED HERE !!!!!!!!------------------------!!!!!!!!!!!!!!!!
private void CreatePushChannel()
{
// 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 Tile events.
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);
// Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
// hereeee uncommnt // System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
//MessageBox.Show(String.Format("Channel Uri is {0}", pushChannel.ChannelUri.ToString()));
}
}
开发者ID:vbhargavmbis,项目名称:Climatica,代码行数:32,代码来源:MainPage.xaml.cs
示例11: Connect
public void Connect()
{
try
{
httpChannel = HttpNotificationChannel.Find(channelName);
if (null != httpChannel)
{
SubscribeToChannelEvents();
SubscribeToNotifications();
Deployment.Current.Dispatcher.BeginInvoke(() => this.UpdateStatus("Channel recovered"));
}
else
{
httpChannel = new HttpNotificationChannel(channelName, "GeoScavChannel");
SubscribeToChannelEvents();
httpChannel.Open();
Deployment.Current.Dispatcher.BeginInvoke(() => this.UpdateStatus("Channel open requested"));
}
}
catch (Exception ex)
{
Deployment.Current.Dispatcher.BeginInvoke(() => UpdateStatus("Channel error: " + ex.Message));
}
}
开发者ID:bdunlay,项目名称:geoscav,代码行数:25,代码来源:NotificationClient.cs
示例12: SetupNotificationChannel
public void SetupNotificationChannel()
{
if (!InternetIsAvailable()) return;
channel = HttpNotificationChannel.Find(channelName);
if (channel == null)
{
channel = new HttpNotificationChannel(channelName);
HookupHandlers();
channel.Open();
}
else
{
HookupHandlers();
try
{
pushClient.RegisterPhoneAsync(WP7App1.Bootstrapper.phoneId, channel.ChannelUri.ToString(), username);
}
catch (Exception ex)
{
throw ex;
}
}
}
开发者ID:HTigran777,项目名称:iQezBan,代码行数:25,代码来源:NotificationManager.cs
示例13: SetupChannel
void SetupChannel()
{
bool newChannel = false;
channel = HttpNotificationChannel.Find(CHANNEL_NAME);
if (channel == null)
{
channel = new HttpNotificationChannel(CHANNEL_NAME);
newChannel = true;
}
channel.ConnectionStatusChanged += channel_ConnectionStatusChanged;
channel.ChannelUriUpdated += channel_ChannelUriUpdated;
channel.ErrorOccurred += channel_ErrorOccurred;
channel.ShellToastNotificationReceived += channel_ShellToastNotificationReceived;
if (newChannel)
{
channel.Open();
channel.BindToShellTile();
channel.BindToShellToast();
}
channelStatus.Text = channel.ConnectionStatus.ToString();
if (channel.ChannelUri != null)
channelUri.Text = channel.ChannelUri.ToString();
}
开发者ID:timothybinkley,项目名称:Windows-Phone-8-In-Action,代码行数:27,代码来源:MainPage.xaml.cs
示例14: 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
示例15: DoConnect
private void DoConnect()
{
try
{
httpChannel = HttpNotificationChannel.Find(channelName);
if (null != httpChannel)
{
SubscribeToChannelEvents();
SubscribeToService();
SubscribeToNotifications();
Dispatcher.BeginInvoke(() => UpdateStatus("Channel recovered"));
}
else
{
httpChannel = new HttpNotificationChannel(channelName, "HOLWeatherService");
SubscribeToChannelEvents();
httpChannel.Open();
Dispatcher.BeginInvoke(() => UpdateStatus("Channel open requested"));
}
}
catch (Exception ex)
{
Dispatcher.BeginInvoke(() => UpdateStatus("Channel error: " + ex.Message));
}
}
开发者ID:nikhildhawan,项目名称:c2dm,代码行数:34,代码来源:MainPage.xaml.cs
示例16: SetupNotificationChannel
public void SetupNotificationChannel()
{
if (!InternetIsAvailable()) return;
channel = HttpNotificationChannel.Find(channelName);
if (channel == null)
{
channel = new HttpNotificationChannel(channelName);
HookupHandlers();
channel.Open();
}
else
{
HookupHandlers();
try
{
channelUri = channel.ChannelUri.ToString();
apiMethodRequest.SendRequest(VkApi.Authorization.AccessToken, "account.registerDevice", new Dictionary<string, string>() { { "token", channelUri } });
}
catch (Exception ex)
{
throw ex;
}
}
}
开发者ID:mikejan,项目名称:EntacikGorc,代码行数:25,代码来源:Notifications.cs
示例17: EntryPage
public EntryPage()
{
InitializeComponent();
StandardTileData sd = new StandardTileData
{
Title = "Property Viewer",
BackgroundImage = new Uri("Background.png", UriKind.Relative),
Count = 0
};
ShellTile st = ShellTile.ActiveTiles.ElementAt(0);
st.Update(sd);
client = new ImageServiceClient();
string channelName = "ChannelName";
httpChannel = HttpNotificationChannel.Find(channelName);
if (httpChannel != null)
{
channelUri = httpChannel.ChannelUri;
client.SetUrlAsync(channelUri);
}
else
{
httpChannel = new HttpNotificationChannel(channelName);
httpChannel.ErrorOccurred += OnErrorOccurred;
httpChannel.Open();
channelUri = httpChannel.ChannelUri;
}
httpChannel.ChannelUriUpdated += OnChannelUriUpdated;
client.resetCompleted += OnResetCompleted;
}
开发者ID:luiscrs14,项目名称:CMOV2,代码行数:32,代码来源:EntryPage.xaml.cs
示例18: 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
示例19: 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
示例20: ChannelUri
protected async override Task<string> ChannelUri()
{
HttpNotificationChannel channel;
string channelName = "ToastChannel";
channel = HttpNotificationChannel.Find(channelName);
if (channel == null)
{
channel = new HttpNotificationChannel(channelName);
}
var tcs = new TaskCompletionSource<string>();
channel.ChannelUriUpdated += (s, e) =>
{
tcs.TrySetResult(e.ChannelUri.ToString());
};
channel.ErrorOccurred += (s, e) =>
{
tcs.TrySetException(new Exception(e.Message));
};
channel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
channel.Open();
channel.BindToShellToast();
return await tcs.Task;
}
开发者ID:lholmquist,项目名称:aerogear-cordova-push,代码行数:28,代码来源:MpnsRegistration.cs
注:本文中的HttpNotificationChannel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论