本文整理汇总了C#中HttpNotificationChannel.BindToShellTile方法的典型用法代码示例。如果您正苦于以下问题:C# HttpNotificationChannel.BindToShellTile方法的具体用法?C# HttpNotificationChannel.BindToShellTile怎么用?C# HttpNotificationChannel.BindToShellTile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpNotificationChannel
的用法示例。
在下文中一共展示了HttpNotificationChannel.BindToShellTile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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;
}
}
示例3: 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;
}
示例4: 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());
}
}
示例5: 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();
}
}
示例6: UpdateLiveTile
public void UpdateLiveTile(Uri liveTileUri, string liveTileTitle, int? liveTileCount, Action onComplete)
{
HttpNotificationChannel toastChannel = HttpNotificationChannel.Find("liveTileChannel");
if (toastChannel != null)
{
toastChannel.Close();
}
toastChannel = new HttpNotificationChannel("liveTileChannel");
toastChannel.ChannelUriUpdated +=
(s, e) =>
{
Debug.WriteLine(String.Format("Is image an absolute Uri: {0}", tileSchedule.RemoteImageUri.IsAbsoluteUri));
if (liveTileUri.IsAbsoluteUri)
{
toastChannel.BindToShellTile(new Collection<Uri> { liveTileUri });
}
else
{
toastChannel.BindToShellTile();
}
SendTileToPhone(e.ChannelUri, liveTileUri.ToString(), liveTileCount, liveTileTitle,
() =>
{
//Give it some time to let the update propagate
Thread.Sleep(TimeSpan.FromSeconds(10));
toastChannel.UnbindToShellTile();
toastChannel.Close();
//Call the "complete" delegate
if (onComplete != null)
onComplete();
}
);
};
toastChannel.Open();
}
示例7: init
public void init(string argsString)
{
Options options;
try
{
options = JsonConvert.DeserializeObject<Options>(JsonConvert.DeserializeObject<string[]>(argsString)[0]);
}
catch (Exception)
{
this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
return;
}
// Prevent double initialization.
if (this.currentChannel != null)
{
this.DispatchCommandResult(new PluginResult(PluginResult.Status.INVALID_ACTION, ALREADY_INITIALIZED_ERROR));
}
// Create or retrieve the notification channel.
var channel = HttpNotificationChannel.Find(options.WP8.ChannelName);
if (channel == null)
{
channel = new HttpNotificationChannel(options.WP8.ChannelName);
SubscribeChannelEvents(channel);
try
{
channel.Open();
}
catch (InvalidOperationException)
{
UnsubscribeChannelEvents(channel);
this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, INVALID_REGISTRATION_ERROR));
return;
}
channel.BindToShellToast();
channel.BindToShellTile();
}
else
{
SubscribeChannelEvents(channel);
}
this.currentChannel = channel;
this.lastChannelUri = null;
this.callbackId = CurrentCommandCallbackId;
// First attempt at notifying the URL (most of the times it won't notify anything)
NotifyRegitrationIfNeeded();
}
示例8: abrirCanalMPNS
private void abrirCanalMPNS()
{
uriChannel = HttpNotificationChannel.Find(vNombreCanal);
if (uriChannel == null)
{
uriChannel = new HttpNotificationChannel(vNombreCanal);
uriChannel.Open();
uriChannel.BindToShellToast();
uriChannel.BindToShellTile();
}
uriChannel.ChannelUriUpdated += uriChannel_ChannelUriUpdated;
uriChannel.ErrorOccurred += uriChannel_ErrorOccurred;
}
示例9: Button_Click_1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
httpChannel = HttpNotificationChannel.Find(channelName);
//如果存在就删除
if (httpChannel != null)
{
httpChannel.Close();
httpChannel.Dispose();
}
httpChannel = new HttpNotificationChannel(channelName, "NotificationServer");
httpChannel.ChannelUriUpdated += httpChannel_ChannelUriUpdated;
httpChannel.ShellToastNotificationReceived += httpChannel_ShellToastNotificationReceived;
httpChannel.HttpNotificationReceived += httpChannel_HttpNotificationReceived;
httpChannel.ErrorOccurred += httpChannel_ErrorOccurred;
httpChannel.Open();
httpChannel.BindToShellToast();
httpChannel.BindToShellTile();
}
示例10: OpenNotificationChannel
public void OpenNotificationChannel()
{
FindNotificationChannel();
if (!(bool)Settings.AllowPushNotifications) {
if (Channel != null) Channel.Close();
return;
}
if (Channel == null)
{
Channel = new HttpNotificationChannel(ChannelName);
Channel.Open();
Channel.BindToShellToast();
Channel.BindToShellTile();
}
Channel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(HttpChannelChannelUriUpdated);
Channel.HttpNotificationReceived += new EventHandler<HttpNotificationEventArgs>(HttpChannelHttpNotificationReceived);
Channel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(HttpChannelErrorOccurred);
Channel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(HttpChannelToastNotificationReceived);
Channel.ConnectionStatusChanged += new EventHandler<NotificationChannelConnectionEventArgs>(HttpChannelConnectionStatusChanged);
}
示例11: MainPage
// Constructor
public MainPage()
{
/// Holds the push channel that is created or found.
HttpNotificationChannel pushChannel;
// The name of our push channel.
string channelName = "MyPushChannel";
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);
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.
System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
MessageBox.Show(String.Format("Channel Uri is {0}",
pushChannel.ChannelUri.ToString()));
}
}
示例12: CreatePushChannel
/// <summary>
///
/// </summary>
/// <param name="channelName"></param>
/// <param name="registrationCallBack">Registration Callback with parameter </param>
/// <param name="messageCallback"></param>
public void CreatePushChannel(String channelName, PushServiceRegistrationCallback registrationCallBack, PushServiceMessageCallback messageCallback)
{
/// Holds the push channel that is created or found.
HttpNotificationChannel pushChannel;
mRegistrationCallback = registrationCallBack;
mMessageCallback = messageCallback;
// 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();
pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
pushChannel.BindToShellToast();
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);
if (pushChannel.IsShellTileBound)
{
pushChannel.UnbindToShellTile();
}
if (pushChannel.IsShellToastBound)
{
pushChannel.UnbindToShellToast();
}
pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
pushChannel.BindToShellToast();
pushChannel.BindToShellTile();
}
}
示例13: openChannel
public void openChannel(string options)
{
try
{
HttpNotificationChannel currentChannel = HttpNotificationChannel.Find(ChannelName);
if (currentChannel == null)
{
currentChannel = new HttpNotificationChannel(ChannelName);
currentChannel.Open();
currentChannel.BindToShellTile();
currentChannel.BindToShellToast();
}
this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, currentChannel.ChannelUri));
}
catch
{
this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
}
}
示例14: Subscribe
private void Subscribe(HttpNotificationChannel pushChannel)
{
// The channel was already open, so just register for all the events.
pushChannel.ChannelUriUpdated += async (sender, e) =>
{
await PushSubscribe(e.ChannelUri);
};
pushChannel.ErrorOccurred += (sender, e) =>
System.Diagnostics.Debug.WriteLine("PushChannel Error: " + e.ErrorType.ToString() + " -> " + e.ErrorCode + " -> " + e.Message + " -> " + e.ErrorAdditionalData);
// Bind this new channel for toast events.
if (pushChannel.IsShellToastBound)
System.Diagnostics.Debug.WriteLine("Already Bound to Toast");
else
pushChannel.BindToShellToast();
if (pushChannel.IsShellTileBound)
System.Diagnostics.Debug.WriteLine("Already Bound to Tile");
else
pushChannel.BindToShellTile();
}
示例15: 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();
System.Diagnostics.Debug.WriteLine("Connetion: " + pushChannel.ConnectionStatus.ToString());
System.Diagnostics.Debug.WriteLine("Bound: " + pushChannel.IsShellTileBound.ToString());
}
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;
System.Diagnostics.Debug.WriteLine("Connetion2: " + pushChannel.ConnectionStatus.ToString());
System.Diagnostics.Debug.WriteLine("Bound2: " + pushChannel.IsShellTileBound.ToString());
}
//if (UriUpdated != null && pushChannel.ChannelUri != null)
//{
// UriUpdated(pushChannel.ChannelUri.ToString());
//}
}