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; }
public void unregister(string options) { Options unregisterOptions; if (!TryDeserializeOptions(options, out unregisterOptions)) { SendError(JSONError); return; } HttpNotificationChannel pushChannel = HttpNotificationChannel.Find(unregisterOptions.WP8.ChannelName); if (pushChannel != null) { pushChannel.UnbindToShellTile(); pushChannel.UnbindToShellToast(); pushChannel.Close(); pushChannel.Dispose(); SendEvent("Channel " + unregisterOptions.WP8.ChannelName + " is closed!"); } else { SendError(MissingChannelError); } }
private void Connect(Action actionIfNotFound) { try { _channel = HttpNotificationChannel.Find(_channelName); } catch (Exception e) { Debug.WriteLine(e.ToString()); } if (_channel != null) { if (_channel.ChannelUri != null) { SubscribeToChannelEvents(); RegisterChannel(_channel.ChannelUri); SubscribeToNotifications(); } else { _channel.UnbindToShellTile(); _channel.UnbindToShellToast(); _channel.Close(); RetryChannelConnect(); } } else { actionIfNotFound(); } }
/// <summary> /// Unsubscribe from pushes at pushwoosh server /// </summary> public void UnsubscribeFromPushes() { if (_registrationService == null) { return; } _notificationChannel.UnbindToShellTile(); _notificationChannel.UnbindToShellToast(); _registrationService.Unregister(); }
public void Unregister() { httpChannel = HttpNotificationChannel.Find(channelName); if (httpChannel != null) { if (httpChannel.IsShellTileBound) { httpChannel.UnbindToShellTile(); } httpChannel.Close(); } onCompeted(); }
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; } }
/// <summary> /// Unsubscribe to Shell tile notifications /// </summary> /// <param name="channel">The active notification channel</param> private void UnSubscribeToTileNotifications(HttpNotificationChannel channel) { // // UnBind to Tile Notification // if (channel.IsShellTileBound == false) { Trace("Already not bound to Tile Notifications"); return; } Trace("Unbinding to Tile Notifications"); channel.UnbindToShellTile(); }
private static void CloseChannel() { if (httpChannel == null) { return; } try { httpChannel.UnbindToShellTile(); httpChannel.UnbindToShellToast(); httpChannel.Close(); } catch (Exception ex) { ShowMessage(ex.Message, "Error Closing Channel"); } }
internal static void BindNotifications() { if (null != _channel) { RegisterDevice(); if (_channel.IsShellTileBound && !DataContextManager.Settings.EnableTileNotifications) { _channel.UnbindToShellTile(); } else if (!_channel.IsShellTileBound && DataContextManager.Settings.EnableTileNotifications) { var uris = new Collection <Uri> { new Uri("http://mobilesrc.com") }; _channel.BindToShellTile(uris); } if (_channel.IsShellToastBound && !DataContextManager.Settings.EnableToastNotifications) { _channel.UnbindToShellToast(); } else if (!_channel.IsShellToastBound && DataContextManager.Settings.EnableToastNotifications) { bool shouldSet = true; if (!DataContextManager.Settings.HasNotifiedToast) { if (MessageBoxResult.OK != MessageBox.Show("Are you sure you want to enable toast notifications?", "Enable Toasts", MessageBoxButton.OKCancel)) { DataContextManager.Settings.EnableToastNotifications = false; shouldSet = false; } DataContextManager.Settings.HasNotifiedToast = true; DataContextManager.Save(); } if (shouldSet) { _channel.BindToShellToast(); } } } }
public void Stop() { FSLog.Debug(); if (NotificationChannel != null) { NotificationChannel.UnbindToShellTile(); NotificationChannel.UnbindToShellToast(); NotificationChannel.Close(); NotificationChannel.ChannelUriUpdated -= NotificationService_ChannelUriUpdated; NotificationChannel.ErrorOccurred -= NotificationService_ErrorOccurred; NotificationChannel.ShellToastNotificationReceived -= NotificationService_ShellToastNotificationReceived; Dispose(); NotificationChannel = null; } }
public void CloseChannel() { HttpNotificationChannel channel = this.TryFindChannel(); if (channel == null) { return; } try { channel.UnbindToShellToast(); channel.UnbindToShellTile(); channel.Close(); } catch (Exception) { Logger.Instance.Error("Failed to close channel"); } }
private void DeleteLocalStorage() { NetworkManager.turnOffNetworkManager = true; App.MqttManagerInstance.disconnectFromBroker(false); App.ClearAppSettings(); App.WriteToIsoStorageSettings(App.IS_DB_CREATED, true); MiscDBUtil.clearDatabase(); HttpNotificationChannel pushChannel = HttpNotificationChannel.Find(HikeConstants.pushNotificationChannelName); if (pushChannel != null) { if (pushChannel.IsShellTileBound) { pushChannel.UnbindToShellTile(); } if (pushChannel.IsShellToastBound) { pushChannel.UnbindToShellToast(); } pushChannel.Close(); } Deployment.Current.Dispatcher.BeginInvoke(() => { App.ViewModel.ClearViewModel(); try { progress.Hide(LayoutRoot); progress = null; } catch { } try { NavigationService.Navigate(new Uri("/View/WelcomePage.xaml", UriKind.Relative)); } catch { } }); }
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(); }
public void onFailure(Exception value) { if ((value is ConnectionException) && ((ConnectionException)value).getCode().Equals(finalmqtt.Msg.ConnAckMessage.ConnectionStatus.BAD_USERNAME_OR_PASSWORD)) { bool isPresent = false; if (App.appSettings.Contains(App.IS_DB_CREATED)) { isPresent = true; } App.ClearAppSettings(); if (isPresent) { App.WriteToIsoStorageSettings(App.IS_DB_CREATED, true); } NetworkManager.turnOffNetworkManager = true; // stop network manager App.MqttManagerInstance.disconnectFromBroker(false); MiscDBUtil.clearDatabase(); HttpNotificationChannel pushChannel = HttpNotificationChannel.Find(HikeConstants.pushNotificationChannelName); if (pushChannel != null) { if (pushChannel.IsShellTileBound) { pushChannel.UnbindToShellTile(); } if (pushChannel.IsShellToastBound) { pushChannel.UnbindToShellToast(); } pushChannel.Close(); } App.HikePubSubInstance.publish(HikePubSub.BAD_USER_PASS, null); } else if (hikeMqttManager.connectionStatus != HikeMqttManager.MQTTConnectionStatus.NOTCONNECTED_WAITINGFORINTERNET) { scheduler.Schedule(hikeMqttManager.connect, TimeSpan.FromSeconds(5)); } hikeMqttManager.setConnectionStatus(windows_client.Mqtt.HikeMqttManager.MQTTConnectionStatus.NOTCONNECTED_UNKNOWNREASON); }
public void unregisterForPush(string options) { PushOptions unregisterOptions; if (!TryDeserializeOptions(options, out unregisterOptions)) { DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } HttpNotificationChannel pushChannel = HttpNotificationChannel.Find(unregisterOptions.ChannelName); if (pushChannel != null) { ChannelListener channelListener; if (channelListeners.TryGetValue(unregisterOptions.ChannelName, out channelListener)) { channelListener.Unsubscribe(pushChannel); channelListeners.Remove(unregisterOptions.ChannelName); } pushChannel.UnbindToShellTile(); pushChannel.UnbindToShellToast(); pushChannel.Close(); #if DEBUG Debug.WriteLine("Unregistered for push on channel " + pushChannel.ChannelName); #endif DispatchCommandResult(new PluginResult(PluginResult.Status.OK)); } else { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, MissingChannelError)); } }
public void Disconnect() { if (_channel != null) { if (_channel.IsShellToastBound) { _channel.UnbindToShellToast(); } if (_channel.IsShellTileBound) { _channel.UnbindToShellTile(); } try { _channel.Close(); } finally { _channel.Dispose(); } } }
/// <summary> /// Unsubscribe to Shell tile notifications /// </summary> /// <param name="channel">The active notification channel</param> private void UnSubscribeToTileNotifications(HttpNotificationChannel channel) { // // UnBind to Tile Notification // if (channel.IsShellTileBound == false) { Trace("Already not bound to Tile Notifications"); return; } Trace("Unbinding to Tile Notifications"); channel.UnbindToShellTile(); }