RegisterAsync() public method

Registers the a notification hub handle with specified notification tags.
public RegisterAsync ( string handle, IEnumerable tags ) : System.Threading.Tasks.Task
handle string The notification handle to register with..
tags IEnumerable The tags to register.
return System.Threading.Tasks.Task
        /// <summary>
        /// Registers the signed in user on the device for push notifications
        /// </summary>
        private async void RegisterForNotifications()
        {
            var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

            try
            {
                var currentUserId      = AppEnvironment.Instance.CurrentUser.UserId;
                var registrationClient = new NotificationRegistrationClient();
                await registrationClient.RegisterAsync(channel.Uri, new[] { "user:" + currentUserId });
            }
            catch (Exception)
            {
                // We can ignore this exception, as this may happend when not internet connection is available.
            }
        }
        /// <summary>
        /// Registers the signed in user on the device for push notifications
        /// </summary>
        private async void RegisterForNotifications()
        {
            var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

            try
            {
                var currentUserId      = AppEnvironment.Instance.CurrentUser.UserId;
                var registrationClient = new NotificationRegistrationClient();
                await registrationClient.RegisterAsync(channel.Uri, new[] { "user:" + currentUserId });
            }
            catch (Exception ex)
            {
                _telemetryClient.TrackException(ex);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Registers the signed in user on the device for push notifications
        /// </summary>
        private async void RegisterForNotifications()
        {
            var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

            try
            {
                var currentUserId = AppEnvironment.Instance.CurrentUser.UserId;
                var registrationClient = new NotificationRegistrationClient();
                await registrationClient.RegisterAsync(channel.Uri, new[] { "user:" + currentUserId });
            }
            catch (Exception)
            {
                // We can ignore this exception, as this may happend when not internet connection is available.
            }
        }