Xamarin.iOS Azure Notification Hub works in Production but second Hub set to Sandbox does not work












0















Goal: I am looking to have a Notification Hub for testing and another for production when publishing the app. Ideally I want to use the Sandbox Notification Hub to target the installation id of my device for testing push notifications.



Note: With Android for testing, I just use the Production Hub to test, and just target the Android installation ID of my device and it works. But iOS Push notifications work with certificates and Sandbox/Production modes.



In Azure I have a Notification Hub Namespace. The Namespace contains two hubs, one set in Production mode, the other set to Sandbox (by flipping the switch)



These are the steps I covered:




  1. The production hub has a production p12 certificate uploaded that was previously exported from the Keychain by right clicking "Apple Push Services: com.company.myappname"


2.The sandbox hub has a sandbox p12 certificate uploaded that was previously exported from the Keychain by right clicking "Apple Development iOS Push Services: com.company.myappname"





  1. There are two Post methods in a web API hosted in Azure for each production and sandbox modes. What differs between the methods is switching the hub and default shared endpoint to their corresponding values in Azure Portal.



        [AllowAnonymous]
    [HttpPost, Route("sendForIOSDevelopment")]
    public async Task<IHttpActionResult> SendTestToIOSInstallationId([FromBody]string message, string installationId)
    {

    if (string.IsNullOrWhiteSpace(installationId))
    {
    var model = new
    {
    error = new
    {
    code = 400,
    message = "installation id is null or empty"
    }
    };
    return Content(HttpStatusCode.BadRequest, model); //400 Bad Request with error message
    }

    //string hubName = "sandboxModeHub";
    string hubName = "productionModeHub";

    //string hubNameDefaultShared = "sandboxModeHubFullSharedEndPoint";
    string hubNameDefaultShared = "productionModeHubFullSharedEndPoint";

    NotificationHubClient hub = NotificationHubClient
    .CreateClientFromConnectionString(hubNameDefaultShared, hubName, enableTestSend: true);

    var templateParams = new Dictionary<string, string>
    {
    ["messageParam"] = message
    };

    NotificationOutcome result = await hub.SendTemplateNotificationAsync(templateParams, "$InstallationId:{" + installationId + "}").ConfigureAwait(false);

    return Ok(result); //200 Ok with model result
    }



4.This is how I register for push notifications in the mobile app:



private 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
var client = new MobileServiceClient(MyAppName.App.MobileServiceUrl);
await client.GetPush().RegisterAsync(deviceToken, templates);

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




  1. To run the Xamarin app in Sandbox mode, I change the Entitlements.plist "aps-environment" key to "development" and use Postman to target the development Post method hosted in the Azure backend.



    What happens is that everything works fine on the Production hub but not on the Sandbox hub.




When I post to the Sandbox hub using the development route to target the development Post method in the Web API i get this :



{
"Success": 0,
"Failure": 0,
"Results": null
}



I cannot figure out why that is up to this point. I did already use my device in both production mode and sandbox to test the app, wondering if that has anything to do with it.










share|improve this question




















  • 1





    Try to uninstall first and reinstall you app to test.Make sure you are using a real device. Also, you can use function NotificationHubClient.GetNotificationOutcomeDetailsAsync(string notificationId) to check if you notification is successfully delivered.

    – Jack Hua - MSFT
    Nov 20 '18 at 5:35


















0















Goal: I am looking to have a Notification Hub for testing and another for production when publishing the app. Ideally I want to use the Sandbox Notification Hub to target the installation id of my device for testing push notifications.



Note: With Android for testing, I just use the Production Hub to test, and just target the Android installation ID of my device and it works. But iOS Push notifications work with certificates and Sandbox/Production modes.



In Azure I have a Notification Hub Namespace. The Namespace contains two hubs, one set in Production mode, the other set to Sandbox (by flipping the switch)



These are the steps I covered:




  1. The production hub has a production p12 certificate uploaded that was previously exported from the Keychain by right clicking "Apple Push Services: com.company.myappname"


2.The sandbox hub has a sandbox p12 certificate uploaded that was previously exported from the Keychain by right clicking "Apple Development iOS Push Services: com.company.myappname"





  1. There are two Post methods in a web API hosted in Azure for each production and sandbox modes. What differs between the methods is switching the hub and default shared endpoint to their corresponding values in Azure Portal.



        [AllowAnonymous]
    [HttpPost, Route("sendForIOSDevelopment")]
    public async Task<IHttpActionResult> SendTestToIOSInstallationId([FromBody]string message, string installationId)
    {

    if (string.IsNullOrWhiteSpace(installationId))
    {
    var model = new
    {
    error = new
    {
    code = 400,
    message = "installation id is null or empty"
    }
    };
    return Content(HttpStatusCode.BadRequest, model); //400 Bad Request with error message
    }

    //string hubName = "sandboxModeHub";
    string hubName = "productionModeHub";

    //string hubNameDefaultShared = "sandboxModeHubFullSharedEndPoint";
    string hubNameDefaultShared = "productionModeHubFullSharedEndPoint";

    NotificationHubClient hub = NotificationHubClient
    .CreateClientFromConnectionString(hubNameDefaultShared, hubName, enableTestSend: true);

    var templateParams = new Dictionary<string, string>
    {
    ["messageParam"] = message
    };

    NotificationOutcome result = await hub.SendTemplateNotificationAsync(templateParams, "$InstallationId:{" + installationId + "}").ConfigureAwait(false);

    return Ok(result); //200 Ok with model result
    }



4.This is how I register for push notifications in the mobile app:



private 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
var client = new MobileServiceClient(MyAppName.App.MobileServiceUrl);
await client.GetPush().RegisterAsync(deviceToken, templates);

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




  1. To run the Xamarin app in Sandbox mode, I change the Entitlements.plist "aps-environment" key to "development" and use Postman to target the development Post method hosted in the Azure backend.



    What happens is that everything works fine on the Production hub but not on the Sandbox hub.




When I post to the Sandbox hub using the development route to target the development Post method in the Web API i get this :



{
"Success": 0,
"Failure": 0,
"Results": null
}



I cannot figure out why that is up to this point. I did already use my device in both production mode and sandbox to test the app, wondering if that has anything to do with it.










share|improve this question




















  • 1





    Try to uninstall first and reinstall you app to test.Make sure you are using a real device. Also, you can use function NotificationHubClient.GetNotificationOutcomeDetailsAsync(string notificationId) to check if you notification is successfully delivered.

    – Jack Hua - MSFT
    Nov 20 '18 at 5:35
















0












0








0








Goal: I am looking to have a Notification Hub for testing and another for production when publishing the app. Ideally I want to use the Sandbox Notification Hub to target the installation id of my device for testing push notifications.



Note: With Android for testing, I just use the Production Hub to test, and just target the Android installation ID of my device and it works. But iOS Push notifications work with certificates and Sandbox/Production modes.



In Azure I have a Notification Hub Namespace. The Namespace contains two hubs, one set in Production mode, the other set to Sandbox (by flipping the switch)



These are the steps I covered:




  1. The production hub has a production p12 certificate uploaded that was previously exported from the Keychain by right clicking "Apple Push Services: com.company.myappname"


2.The sandbox hub has a sandbox p12 certificate uploaded that was previously exported from the Keychain by right clicking "Apple Development iOS Push Services: com.company.myappname"





  1. There are two Post methods in a web API hosted in Azure for each production and sandbox modes. What differs between the methods is switching the hub and default shared endpoint to their corresponding values in Azure Portal.



        [AllowAnonymous]
    [HttpPost, Route("sendForIOSDevelopment")]
    public async Task<IHttpActionResult> SendTestToIOSInstallationId([FromBody]string message, string installationId)
    {

    if (string.IsNullOrWhiteSpace(installationId))
    {
    var model = new
    {
    error = new
    {
    code = 400,
    message = "installation id is null or empty"
    }
    };
    return Content(HttpStatusCode.BadRequest, model); //400 Bad Request with error message
    }

    //string hubName = "sandboxModeHub";
    string hubName = "productionModeHub";

    //string hubNameDefaultShared = "sandboxModeHubFullSharedEndPoint";
    string hubNameDefaultShared = "productionModeHubFullSharedEndPoint";

    NotificationHubClient hub = NotificationHubClient
    .CreateClientFromConnectionString(hubNameDefaultShared, hubName, enableTestSend: true);

    var templateParams = new Dictionary<string, string>
    {
    ["messageParam"] = message
    };

    NotificationOutcome result = await hub.SendTemplateNotificationAsync(templateParams, "$InstallationId:{" + installationId + "}").ConfigureAwait(false);

    return Ok(result); //200 Ok with model result
    }



4.This is how I register for push notifications in the mobile app:



private 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
var client = new MobileServiceClient(MyAppName.App.MobileServiceUrl);
await client.GetPush().RegisterAsync(deviceToken, templates);

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




  1. To run the Xamarin app in Sandbox mode, I change the Entitlements.plist "aps-environment" key to "development" and use Postman to target the development Post method hosted in the Azure backend.



    What happens is that everything works fine on the Production hub but not on the Sandbox hub.




When I post to the Sandbox hub using the development route to target the development Post method in the Web API i get this :



{
"Success": 0,
"Failure": 0,
"Results": null
}



I cannot figure out why that is up to this point. I did already use my device in both production mode and sandbox to test the app, wondering if that has anything to do with it.










share|improve this question
















Goal: I am looking to have a Notification Hub for testing and another for production when publishing the app. Ideally I want to use the Sandbox Notification Hub to target the installation id of my device for testing push notifications.



Note: With Android for testing, I just use the Production Hub to test, and just target the Android installation ID of my device and it works. But iOS Push notifications work with certificates and Sandbox/Production modes.



In Azure I have a Notification Hub Namespace. The Namespace contains two hubs, one set in Production mode, the other set to Sandbox (by flipping the switch)



These are the steps I covered:




  1. The production hub has a production p12 certificate uploaded that was previously exported from the Keychain by right clicking "Apple Push Services: com.company.myappname"


2.The sandbox hub has a sandbox p12 certificate uploaded that was previously exported from the Keychain by right clicking "Apple Development iOS Push Services: com.company.myappname"





  1. There are two Post methods in a web API hosted in Azure for each production and sandbox modes. What differs between the methods is switching the hub and default shared endpoint to their corresponding values in Azure Portal.



        [AllowAnonymous]
    [HttpPost, Route("sendForIOSDevelopment")]
    public async Task<IHttpActionResult> SendTestToIOSInstallationId([FromBody]string message, string installationId)
    {

    if (string.IsNullOrWhiteSpace(installationId))
    {
    var model = new
    {
    error = new
    {
    code = 400,
    message = "installation id is null or empty"
    }
    };
    return Content(HttpStatusCode.BadRequest, model); //400 Bad Request with error message
    }

    //string hubName = "sandboxModeHub";
    string hubName = "productionModeHub";

    //string hubNameDefaultShared = "sandboxModeHubFullSharedEndPoint";
    string hubNameDefaultShared = "productionModeHubFullSharedEndPoint";

    NotificationHubClient hub = NotificationHubClient
    .CreateClientFromConnectionString(hubNameDefaultShared, hubName, enableTestSend: true);

    var templateParams = new Dictionary<string, string>
    {
    ["messageParam"] = message
    };

    NotificationOutcome result = await hub.SendTemplateNotificationAsync(templateParams, "$InstallationId:{" + installationId + "}").ConfigureAwait(false);

    return Ok(result); //200 Ok with model result
    }



4.This is how I register for push notifications in the mobile app:



private 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
var client = new MobileServiceClient(MyAppName.App.MobileServiceUrl);
await client.GetPush().RegisterAsync(deviceToken, templates);

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




  1. To run the Xamarin app in Sandbox mode, I change the Entitlements.plist "aps-environment" key to "development" and use Postman to target the development Post method hosted in the Azure backend.



    What happens is that everything works fine on the Production hub but not on the Sandbox hub.




When I post to the Sandbox hub using the development route to target the development Post method in the Web API i get this :



{
"Success": 0,
"Failure": 0,
"Results": null
}



I cannot figure out why that is up to this point. I did already use my device in both production mode and sandbox to test the app, wondering if that has anything to do with it.







azure xamarin.forms push-notification xamarin.ios apple-push-notifications






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 2:02







EmilRR1

















asked Nov 16 '18 at 1:48









EmilRR1EmilRR1

896




896








  • 1





    Try to uninstall first and reinstall you app to test.Make sure you are using a real device. Also, you can use function NotificationHubClient.GetNotificationOutcomeDetailsAsync(string notificationId) to check if you notification is successfully delivered.

    – Jack Hua - MSFT
    Nov 20 '18 at 5:35
















  • 1





    Try to uninstall first and reinstall you app to test.Make sure you are using a real device. Also, you can use function NotificationHubClient.GetNotificationOutcomeDetailsAsync(string notificationId) to check if you notification is successfully delivered.

    – Jack Hua - MSFT
    Nov 20 '18 at 5:35










1




1





Try to uninstall first and reinstall you app to test.Make sure you are using a real device. Also, you can use function NotificationHubClient.GetNotificationOutcomeDetailsAsync(string notificationId) to check if you notification is successfully delivered.

– Jack Hua - MSFT
Nov 20 '18 at 5:35







Try to uninstall first and reinstall you app to test.Make sure you are using a real device. Also, you can use function NotificationHubClient.GetNotificationOutcomeDetailsAsync(string notificationId) to check if you notification is successfully delivered.

– Jack Hua - MSFT
Nov 20 '18 at 5:35














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330334%2fxamarin-ios-azure-notification-hub-works-in-production-but-second-hub-set-to-san%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330334%2fxamarin-ios-azure-notification-hub-works-in-production-but-second-hub-set-to-san%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?