4
votes

I am running around to get this push notification functionality working (for 4 days now) in my app by using Azure Notification Hubs or Azure App Service Mobile App. It's been hard to find even a basic sample for sending Push Notifications to my mobile app (used as regular desktop website too) that I have created in Ionic 2.

To add to this, I am completely new to Azure Cloud Services in general and to Notification Hubs and/or Mobile Apps. Maybe, that's causing me not to look at the right place.

Microsoft Azure documentation for Notification Hubs and Mobile Apps is very confusing to me. I mean, I am not able to follow their docs and figure out a way to implement push notification functionality for my Ionic 2 Hybrid app. All the docs revolve around Visual Studio and .Net (not my skill set) so I am not able to figure out the solution for my work.

After reading more and more, it appears that I do not need Mobile Apps feature in Azure. I think one needs to use it only if they plan to have a cloud backend of their mobile apps. In my case, I have my own setup to deploy my app.

So that leaves me with Notification Hubs. I have created a Notification Hub in Azure Portal.

  1. I was also able to register my app in Google FCM (formerly, GCM, I suppose). That is, creating a new app in Firebase Cloud Management Console and getting its Server Key along with Sender ID.

  2. I also know where in Notification Hub I need to add that Server Key (in Notification Services > GCM).

  3. I also have the Connection String from "Access Policies" of my newly created Notification Hub.

  4. Finally, I understand that I will have to get similar information from Apple, Windows, Windows Phone services in order to send the push notifications to my app on those platforms.

Having done all of the above, I still do not know what exactly do I need to do next to get the push notification functionality working.

I would appreciate if you could please help me in the following:

  • Does anybody have a good material or a link on how to use Azure Notification Hubs to send push notifications to an hybrid app (like Ionic 2 and Cordova, etc.)?

  • Or a simple sample showing what artifacts go where in setting this up? Like, what I need to do in Azure Cloud in addition to what I have done above. And what all I need to do on my app side.

I would highly appreciate if somebody could please guide me in the right directions.

3
Thanks for your suggestion, Nikita, I did land on that link previously. However, it shows how to do things using Visual Studio and .Net. So, as soon as I reach that part, I loose track of things. I am using Visual Studio Code for my development and no .Net. I don't know .Net, I can work with Node. Will give it another try.Gauzy
forget about those steps and go next step its fine we don't need back end for testing notifications .Ganesh Manoj

3 Answers

2
votes

I was also stuck there for little bit because no one really gives you a good high level description of what the parts do. Here's a summary of just Firebase and Android.

As you mentioned you already created your Firebase project and registered that with your notification hub.

In your Android app, you set it up to use Firebase and get a token when it connects. That token lets you deliver notifications to that device and that app. The app doesn't need to know anything about the notification hub. As far as it's concerned all the notifications come from firebase.

Where the notification hub fits in is you take that token and register it with the hub along with some tag values. While the app can technically do this registration, usually it's just going to pass its token to your backend server which will then register with the hub for the device.

Once that token from the device is registered with a tag, you can now send a message to that tag on the notification hub and it will forward it to the firebase server which will then send it out to the device.

Another key part is along with registering the token with tag values, you can also register it with a template. The template is the format that device is expecting and the hub will rewrite a generic notification into the device specific format. That means you can send one message to a tag on the hub and all the devices registered for that tag will receive the message reformatted to match what their platform requires. That's pretty much the whole reason for using the hub verse just sending to each platform service directly.

How you use tags is up to you. A common model would be assign each of your users a unique tag and then register each of their devices with that tag when they log into your server. That means they get their notifications on all their devices regardless of platform.

0
votes
  • Yes, you don't need the Azure Mobile App Service, just configure an Azure Notification Hub (add the server keys for the platforms you want to support).
  • Use the Notification Hubs REST Api in your app and backend instead of the .NET wrapper.
0
votes

Just follow these two steps

For creating application in our platform and app service

Adding notification hub

By test send in notification hub you can check notifications don't worry about back end code.

with out app service also we can send notification by using only notification hub using its connection string

With out using app service