private void SendPushTokenToAzure()

in src/Covi.iOS/AppDelegate.cs [118:159]


        private void SendPushTokenToAzure(NSData deviceToken)
        {
            try
            {
                var hub = new SBNotificationHub(Constants.PushNotificationsConstants.ListenConnectionString, Constants.PushNotificationsConstants.NotificationHubName);

                // update registration with Azure Notification Hub
                hub.UnregisterAll(deviceToken, (error) =>
                {
                    if (error != null)
                    {
                        Debug.WriteLine($"Unable to call unregister {error}");
                        return;
                    }

                    var tags = new NSSet(Constants.PushNotificationsConstants.SubscriptionTags.ToArray());
                    hub.RegisterNative(deviceToken, tags, (errorCallback) =>
                    {
                        if (errorCallback != null)
                        {
                            Debug.WriteLine($"RegisterNativeAsync error: {errorCallback}");
                        }
                    });

                    var templateExpiration = DateTime.Now.AddDays(120)
                        .ToString(System.Globalization.CultureInfo.CreateSpecificCulture("en-US"));
                    hub.RegisterTemplate(deviceToken, "defaultTemplate", Constants.PushNotificationsConstants.APNTemplateBody, templateExpiration, tags,
                        (errorCallback) =>
                        {
                            if (errorCallback != null)
                            {
                                Debug.WriteLine($"RegisterTemplateAsync error: {errorCallback}");
                            }
                        });
                });
            }
            catch (Exception ex)
            {
                Debugger.Break();
                _logger.LogError(ex, "Failed to send push notification token to Azure Hub");
            }
        }