/// <summary> /// Asynchronously unregisters the native registration on the application or secondary tiles. /// </summary> /// <param name="options"></param> public async void unregisterApplication(string options) { try { var args = JsonHelper.Deserialize <List <string> >(options); var notificationHubPath = args[0]; var connectionString = args[1]; if (string.IsNullOrEmpty(notificationHubPath)) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "notificationHubPath can't be null or empty")); return; } if (string.IsNullOrEmpty(connectionString)) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "connectionString can't be null or empty")); return; } var hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(notificationHubPath, connectionString); await hub.UnregisterNativeAsync(); DispatchCommandResult(new PluginResult(PluginResult.Status.OK)); } catch (Exception ex) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ex.Message)); } }
private async Task<string> RegisterNativeAsyncInternal(string notificationHubPath, string connectionString, string channelUri, string[] tags) { // Create the notification hub var hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(notificationHubPath, connectionString); // Register with the Notification Hub, passing the push channel uri and the string array of tags var registration = await hub.RegisterNativeAsync(channelUri, tags); return registration.RegistrationId; }
private async Task <string> RegisterNativeAsyncInternal(string notificationHubPath, string connectionString, string channelUri, string[] tags) { // Create the notification hub var hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(notificationHubPath, connectionString); // Register with the Notification Hub, passing the push channel uri and the string array of tags var registration = await hub.RegisterNativeAsync(channelUri, tags); return(registration.RegistrationId); }
/// <summary> /// Register this application to the Notification Hub Service /// </summary> private async void InitNotificationsAsync() { PushNotificationChannel channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); Microsoft.WindowsAzure.Messaging.NotificationHub hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(hubName, hubListenEndpoint); Microsoft.WindowsAzure.Messaging.Registration result = await hub.RegisterNativeAsync(channel.Uri); //If registration was successful, subscribe to Push Notifications if (result.RegistrationId != null) { Debug.Log($"Registration Successful: {result.RegistrationId}"); channel.PushNotificationReceived += Channel_PushNotificationReceived; } }
private async void CompleteApplicationRegistration(string channelUri, string notificationHubPath, string connectionString) { try { var hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(notificationHubPath, connectionString); var registration = await hub.RegisterNativeAsync(channelUri); var regInfo = new RegisterResult(); regInfo.RegistrationId = registration.RegistrationId; regInfo.ChannelUri = registration.ChannelUri; regInfo.NotificationHubPath = registration.NotificationHubPath; DispatchCommandResult(new PluginResult(PluginResult.Status.OK, regInfo)); } catch (Exception ex) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ex.Message)); } }
public async void UnregisterNativeAsync(string notificationHubPath, string connectionString) { var hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(notificationHubPath, connectionString); await hub.UnregisterNativeAsync(); }
/// <summary> /// Asynchronously unregisters the native registration on the application or secondary tiles. /// </summary> /// <param name="options"></param> public async void unregisterApplication(string options) { try { var args = JsonHelper.Deserialize<List<string>>(options); var notificationHubPath = args[0]; var connectionString = args[1]; if (string.IsNullOrEmpty(notificationHubPath)) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "notificationHubPath can't be null or empty")); return; } if (string.IsNullOrEmpty(connectionString)) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "connectionString can't be null or empty")); return; } var hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(notificationHubPath, connectionString); await hub.UnregisterNativeAsync(); DispatchCommandResult(new PluginResult(PluginResult.Status.OK)); } catch (Exception ex) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ex.Message)); } }
private async void CompleteApplicationRegistration(string channelUri, string notificationHubPath, string connectionString) { try { var hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(notificationHubPath, connectionString); var registration = await hub.RegisterNativeAsync(channelUri); var regInfo = new RegisterResult(); regInfo.RegistrationId = registration.RegistrationId; regInfo.ChannelUri = registration.ChannelUri; regInfo.NotificationHubPath = registration.NotificationHubPath; DispatchCommandResult(new PluginResult(PluginResult.Status.OK, regInfo)); } catch (Exception ex) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ex.Message)); } }
private async void CompleteApplicationRegistration(string channelUri, string notificationHubPath, string connectionString, string tags) { try { var hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(notificationHubPath, connectionString); List<string> tagCollection = new List<string>(); if (tags.Contains(",")) { foreach (string tag in tags.Split(',')) { tagCollection.Add(tag); } } else { tagCollection.Add(tags); } var registration = await hub.RegisterNativeAsync(channelUri, tagCollection); var regInfo = new RegisterResult(); regInfo.RegistrationId = registration.RegistrationId; regInfo.ChannelUri = registration.ChannelUri; regInfo.NotificationHubPath = registration.NotificationHubPath; regInfo.Tags = registration.Tags; DispatchCommandResult(new PluginResult(PluginResult.Status.OK, regInfo)); } catch (Exception ex) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ex.Message)); } }
public async void UnregisterNativeAsync(string notificationHubPath, string connectionString) { var hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(notificationHubPath, connectionString); await hub.UnregisterNativeAsync(); }
public async void Register(string connectionString, string hubName, string token, string[] tags) { hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(hubName, connectionString); var result = await hub.RegisterNativeAsync(token, tags); }