question

marc-8366 avatar image
0 Votes"
marc-8366 asked ajkuma-MSFT answered

Azure Notification Hub Application mode using production fails

I followed this tutorial and got the notification hub working for my app in sandbox mode and "Token" is used as authentication method.
https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-ios-push-notifications-swift-apps-get-started

I am not sure what the difference is between production and sandbox mode but i guess when I push the app to appstore then the production mode is supposed to be used. After swiching from "sandbox" to "production", the test send generates following outcome "the push notifiication system handler for the registration is invalid".
I mean it is working under "sandbox" mode, which means the devices are using the correct "listen" connectionstring.

azure-notification-hubs
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ajkuma-MSFT avatar image
1 Vote"
ajkuma-MSFT answered

[Adding the offline discussion with @marc-8366 here, to benefit the community]

The documentation calls out when you’re creating your app, to create certificates for both production and development, which are used for push notifications.
This has to do with the production or development case doc: or you can use the token based authentication as discussed in option 2.

Once those certs or tokens have been created, then you need to create a provisioning profile, either production or development mode so that you can deploy the app. Once the device has been registered for development by the app, it is good only for development, not production. Then the development credentials should be set on the Notification Hub, depending on the method chosen either the p12 or p8 file.

In other words as noted here, when you build your app using a development cert, the app will generate a unique device token. This device token will not work on the production push network. When you then build your app with a distribution provisioning profile (App Store or Ad-Hoc) your device will generate a different device token for push notifications. If you try to send the development generated token to the production push SSL network, Apple's servers will reject your token.

Update from @marc-8366 - " I did get the problem solved after only using the production hub + app downloaded from testflight using appstore provision profile. And everytime i do local development then I just use the local development hub connectionstring, else cant get it work locally with my dev provision profile."

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ajkuma-MSFT avatar image
0 Votes"
ajkuma-MSFT answered ajkuma-MSFT edited

Welcome to Microsoft Q&A! Thanks for posting this question.

Apologies for the delay and any inconvenience with this issue.

Just to confirm, are you using the same hub or two different hubs with sandbox and production certificates?
You must maintain two different hubs: one for production and another for testing. You must upload the certificate you use in a sandbox environment to a separate hub than the certificate/hub you'll use in production. Don't try to upload different types of certificates to the same hub. It will cause notification failures. If you inadvertently upload different types of certificates to the same hub, you should delete the hub and start fresh with a new hub. If for some reason you can't delete the hub, you must at least delete all the existing registrations from the hub.

You may check the steps outlined in the document – ‘Diagnose dropped notifications in Azure Notification Hubs’ to narrow down the issue further.

As mentioned, the tutorial you are referring for configuring deployment certificate, the same process is used when registering a production certificate. Just make sure that you use the same certificate type when sending notifications.
Also, just highlighting the points from the same document :

  • The notification hub will be configured to use the Sandbox authentication mode only. You should not use this authentication mode for production workloads.

  • This tutorial uses a development certificate. The same process is used when registering a production certificate. Just make sure that you use the same certificate type when sending notifications.

  • Use the Production for Application Mode only if you want to send push notifications to users who purchased your app from the store.



Kindly let us know if this helps or you need further assistance we would be more than happy to assist you.






5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

marc-8366 avatar image
0 Votes"
marc-8366 answered ajkuma-MSFT commented

Hi, my setup is using two hubs, one for local development testing and one for production. And i am not using certificate, but the token key. The key itself is general purpose and can be used by both testing and production.

Use the Production for Application Mode only if you want to send push notifications to users who purchased your app from the store.

this is actually the part that I did not manage to understand earlier until now. When the production mode is used, the notification is routed to the production server from apple. When I am debugging locally, i am using a development provision profile, and I never managed to receive any notification. As for today, I push the app to testflight, then install it from there, so the app is using the appstore provision profile. It seems app is only able to receive production notification when production provision profile is used. I think without this explanation, we as developer will have a hard time to understand what is going on by reading the returned "outcome" object.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@marc-8366, Apologies! the issue is still not resolved. I wish to engage with you offline for a closer look and provide a quick and specialized assistance, please send an email with subject line “Attn:Ajay” to AzCommunity[at]Microsoft[dot]com referencing this thread and the Azure subscription ID, I will follow-up with you.

Sorry the statement/note in the documentation is not very clear, I have been discussing on this internally and will share more details on this further and relay this to our content team for further review. Thanks for your feedback on this.

Once again, apologies for the inconvenience with this issue.
Thanks for your patience and co-operation.

0 Votes 0 ·