In Azure it possible to have two notification hubs for same web API in prod/development modes?

Cdn_EuroCdn_Euro Member ✭✭✭

I currently have a mobile app receiving push notifications through a notification hub in Azure and a web API back end.

On the Azure portal I see that the back end is associated with the notification hub currently set to production for Apple APNS, as seen in photo below.

Within the mobile app, in the Xamarin iOS project, the registration with the back-end is performed as follows:

async Task SendRegistrationToServerAsync(NSData deviceToken)
        {
            //this is the template/payload used by iOS. It contains the "messageParam"
            // that will be replaced by our service

            const string templateBodyAPNS = @"{
                                                ""aps"" : {
                                                    ""alert"" : ""$(messageParam)"",
                                                    ""mutable-content"": 1
                                                },
                                            }";


            var templates = new JObject();
            templates["genericMessage"] = new JObject
            {
                {"body", templateBodyAPNS }
            };

            // send registration to web api
            // MobileServiceUrl points to the Web API mentioned above
            var client = new MobileServiceClient(MyMobileAppName.App.MobileServiceUrl); 
            await client.GetPush().RegisterAsync(deviceToken, templates);

            //get the installation id
            Console.WriteLine("Installation id1: " + client.InstallationId.ToString());
        }

The questions are:

In Application Settings can I added another HubName and HubId (to separate development and production) and also add the associated second connection string for it in Connection strings.Will registering with the web API in the code line above automatically detect which hub is in development and which is in production depending on the environment the application is run in?

OR Will there be an error for having two hubs associated with the same web api and the application will not function properly?

Sign In or Register to comment.