Azure NotificationHub Invalid credentials when sending push - azure

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

Related

How to get a callback when an Azure Marketplace Managed Application is installed from marketplace

The Microsoft documentation states:
Provide a notification endpoint URL: In the Notification Endpoint URL
box, provide an HTTPS Webhook endpoint to receive notifications about
all CRUD operations on managed application instances of this plan
version.
I created a simple Logic App and copied the HTTP endpoint into my MPN App Plan under the
It looks like this and has the sig at the end:
https://prod-08.australiaeast.logic.azure.com:443/workflows/fe287d1b9a8c48619a1b44765dad6dc7/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=C9JYfNPjvq-efsLwW66A4K4zTgx6qxGT1oH0RZZRsI0
To test it I hit it with PostMan and confirm that it is getting an HTTP200 as per the MS Docs.
I publish the app to the marketplace:
(you can see the app live here - https://azuremarketplace.microsoft.com/en-us/marketplace/apps/data-drivenai1581501556049.cloudmonitor-analytics-engine)
However - the endpoint never gets called at all. I can see in the logs that no attempt (failed or past) has been made to call it.
I raised a Microsoft Support Ticket and asked a Technical Specialist, however no one can tell me how to debug it or why it is not calling back on installs or failed installs.
Has anyone seen this working?
Update
I found out that each PLAN has a GUID that is automatically used for deployment. Mine is "pid-34881ea9-xxxx--xxxx-xxxx-2cf731e06ef7-partnercenter" - should I be putting this on the callback notification URL as sig=ThisGUID?
In the example for Managed apps with notifications, it shows that managed applications will send a post to https://{your_endpoint_URI}/resource. Can you try adding /resource to your listener and see if it triggers your logic app? I believe that should fix this.

How to resolved Invalid Credential error in ANH for iOS?

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

Azure Test Send Not Working

I have an android application in which I am trying to implement Azure Push Notification. I am doing the following steps:
Create an android application.
Register the android application developed in step one to get the token id.
Create a project in the Firebase Console and copy the legal server key.
Create a notification hub.In the notification hub under gcm register the legal server key generated in step 3.
Send a notification through test send feature of the azure portal.
I am getting success message but nothing is delivered to the device. Am I missing any step? Please suggest my work is stuck because of this.

Azure mobile apps: can't send push notifications from my nodeJS back-end

First, I should clarify that I'm only using free modules and service plans on the Azure side, using a Bizspark subscription.
I'm currently trying to run the app in the following tutorial:
https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-push
Everything works on the client side, items are correctly sent and stored in the database. However, I can't make the NodeJS server send push notifications to devices.
I basically copy and pasted the code on the tutorial for the nodeJS back-end on the tutorial, redeployed/restarted the server, but not a single push notification is sent.
I tried to see where in the code something was wrong, so I went and used some logger.info here and there. I then found out that context.push is undefined.
However, I did connect the mobile app to the notification hub in the "push" category in the menu of my mobile-app in Azure (it does appear connected).
Push page on my mobile app
Google cloud messaging is also correctly configured, I get the push notification for the successful registration when I start the app.
What am I missing? Is it because I'm using free plans (notification hub, database, service plan)?
First of all, you could test sending notifications via the Azure portal, to do this, please see steps below.
Go to the Azure portal and navigate to your notification hub.
Click on Test Send under the SUPPORT + TROUBLESHOOTING menu.
Select the platform you used, then fill payload message and click Send button.
Almost immediately (but in reality, it could be a few minutes because of PNS delays), you will see the push notification alert on your application.
For node.js backend on Azure mobile apps, you could use the following lines of code to send a push notification to all registered clients.
var payload = {
data: {
message: 'Hello!'
}
};
notificationHubService.gcm.send(null, payload, function(error){
if(!error){
//notification sent
}
});
For more info, please check out this tutorial.
I did try the test send a few times and it worked perfectly, hence why I couldn't understand how it couldn't work. I couldn't use the exact same code #aaron-chen-msft posted as I use the basic back-end nodeJS server on Azure (the quickstart one, so I would need to install the "azure" npm package), but I added the following string to my mobile app settings (application settings tab) on azure:
key : MS_NotificationHubName value : MyNotificationHubName (here, Poke-Forgh)
Context.push was then not undefined, but the notifications weren't sent, so I got inspired by #aaron-chen-msft's code and I edited the nodeJS code to specifically send notifications to GCM:
context.push.gcm.send(null, payload, function (error) { ... }
And it finally worked. Thanks!

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.

Resources