How to resolved Invalid Credential error in ANH for iOS? - azure

I've set up an Azure Notification Hub and I have gone through all the steps to implement Push Notification into my iOS app. The app has been working fine, receiving the push notifications just like it should. Then today I went to try and send a push from the Azure Portal and it failed.
It seems to be only iOS related though, as the devices that run my app in Android are receiving the Push Notification like they should. I know for a fact I have not changed anything in my code. But instead of getting the Push Notification like I should I now get the following message in Azure portal.
The Push Notification System rejected the request because of an
Invalid Credential.
Any idea about this?

I have just resolved this issue. Just create new APNS certificates and add it to Azure Portal APNS settings. Now it works fine. But Why this is happened I don't understand that. If anyone have idea regarding this then please share it.
If any other solution then please share it here.
Thanks.

This is a potential explanation to your problem.
When you configure APNS into an ANH (Azure Notification Hub), you have the choice between 2 approaches:
Certificate
Token
Of what I understood, you have used "certificate", and APNS certificate expires every year:
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_certificate-based_connection_to_apns
So maybe, your certificate has expired, and when you created a new one, it has solved your issue.
The other approach with "Token", has the advantage of never expiring.
Regards,
Loic

Related

Updating apns credentials in azure notification hubs causing error in portal

I'm trying to update the existing APNS Credential for my Azure notification hub.
Regardless if I try to upload a new certificate or click "Delete Credential" I get the same error:
Error updating notification hub
{"error":{"message":"Object reference
not set to an instance of an object.","code":"InternalServerError"}}
If I check the developer console in the browser, there's a PATCH request made, where the only parameter is pnsCredential: null.
I've tried multiple browsers and computers with same results.
Thank you for your edit, it is correct: this was a transient issue in the Notification Hubs creation. This is now resolved and we are not expecting that specific issue to happen again.
Thanks, Karl
Updating for anyone else who may find this.
This seems to have been an issue on Azure Portal. It has since been resolved and now works as expected, without any further action on my end.
I did report it to #AzureSupport but have not heard of any action taken by them, so not sure if that is why it was resolved.

Azure Notification Hub and Apple APNS Push Notifications unregistering devices

I am currently working on an application built in VS using a Xamarin Unified IOS project. one requirement of the application is the utilisation of push notifications. The issue is that our test device/application registers in the first instance without any issues, we can see the registration events in azure portals, and the azure service bus. I have also confirmed the initial registration using the 'Service Bus Explorer' application and the server explorer feature in VS.
The issue arises when sending the test push notification. According to all the logs I have access too the message is successfully pushed to apples APNS server and I can't see any failures being returned as part of the PNS request. However once this completed the device registration is removed and the notification never arrives on the test device.
My understanding is that the azure application hub handles PNS rejections itself in order to tidy up device registrations. This in and of itself is not a terrible idea, but due to a lack of logging, it's very hard to determine the root cause. I have done a ridiculous amount of googling for this one, and a lot of people suggest an issue with the apple certificates that are used. I have deleted, recreated, resigned, verified, both APNS certs and Provisioning profiles until I ran out of combinations. None of that has resolved the issue.
To make the issue more confusing, if I use a service such as 'http://pushtry.com' or 'http://pushwatch.com' and upload the certificate and device token, it will allow me to successfully push a notification to the device.
Am I missing something glaringly obvious? or is the notification hub absurdly difficult to setup and debug for APNS?
Any help you can provide will be appreciated, I would publish some code, but as I know that the device registers the correct device token, I don't see it necessary at this point, but please feel free to tell me otherwise. Many thanks.
What's also important to note, if you are using Azure Notification Hubs APNS, is that it will unregister devices if the application mode is not set to in production. Once you have deployed to the app store, you need to switch the "application mode" in your Azure Notification Hub from sandbox to production. Otherwise your device registrations will be unregistered.
I'm using the same token/key for both sandbox and production with no issues.
After many man hours and through luck rather than any kind of logical process, we determined that 'Azure Notification Hubs' have an in built validator for the apple device token that's passed up to the APNS. So even though there are multiple examples and answers out there that suggest submitting a device token without spaces or symbols to the notification hub, this is in fact the wrong approach. The device token should always be submitted to the 'Azure Notification Hub' in an 'as is' state, without any validating from within the Xamarin.IOS application. Although this seems like such a simple thing to overlook, there is a lot of contradictory evidence out there on google, and Azure's documentation says very little about the format of submitted device tokens. Anyway hopefully this will help someone else someday.
-- Edit --
Device Token format from Apple: < XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX >
Format that many online resources suggest it is passed to the notification hub as: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
without spaces or the '<' and '>'
However it should be passed through to the notification hub as it is received from Apple.

Azure NotificationHub Invalid credentials when sending push

I've set up an Azure Notification Hub and I have gone through all the steps to incorporate Push Notification into my Android app. The app has been working fine, receiving the push notifications just like it should. Then today I went to try and send a push and it failed. So I tried from the Azure Portal and it failed there too.
It seems to be only Android related though, as the devices that run my app in iOS are receiving the Push Notification like they should. I know for a fact I have not changed anything in my code. But instead of getting the Push Notification like I should I now get the following message in Azure portal.
The Push Notification System rejected the request because of an invalid credential
Does anyone have any idea why this would happen? I'm stumped.
I thought at first maybe it was something with my API key (which again I have not changed) so I checked. The Google Cloud Message API Key in the Azure Portal matches what I have in my Google API Console, so it's not that.
What could it be?
Ok, so here is how I fixed my issue:
In Google API Manager I used to only have an api key of type - Android
I created another key of type - Server, and copied that into my azure gcm config, and away she goes... notifications working again

Failed to send push notification in ios

i'm using azure mobile service to send push notification.In Last month,I can send push notification.
but yesterday, sending to apns is failed with following log
[Error: wrong tag] scheduler/expectationNotification
I've never seen this before, and a Bing/Google search comes up with nothing.
I using two azure mobile service. One is no problem,but the other is failed.
What do not people more about this issue?
You should reload your APNS certificate in the portal and the problem should go away.

push notifications with azure in windows phone 8 app

I am using Azure services in my windows phone 8 app to send push notifications and toast notifications by following the steps mentioned here.
However as mentioned in the comments below on the link, HttpNotificationChannel does not have a Uri property, it's ChannelUri, so the code to create a new Registrations object need to be changed.
Could anyone suggest a turnaround or a solution to this bug?
Thanks!
Try
Handle = CurrentChannel.ChannelUri.ToString();

Resources