Search code examples
c#azureapple-push-notificationsazure-notificationhub

azure CreateNotificationHub with Sandbox programmatically


I have to create a notificationhub programmatically with Sandbox mode for iOS devices(for development and testing). Not sure how to configure that. Below is the code I am using for creating the hub

                NotificationHubDescription notificationHubDescription = new NotificationHubDescription(hubName);
            notificationHubDescription.ApnsCredential = new ApnsCredential(certificateFile, certificatePassword);

            if (!namespaceManager.NotificationHubExists(hubName))
            {
                notificationHubDesc = namespaceManager.CreateNotificationHub(notificationHubDescription);
            }

Solution

  • Got solution - Need to set following in the code. Weird that this is not mentioned in the document by Azure

                    if (!isForProduction)
                    apns.Endpoint = "gateway.sandbox.push.apple.com";