Use Azure Notifications Hub with Firebase and iOS (not APNS) - firebase

I am looking at using Azure Notifications Hub for device registrations on the backend. I was thinking about using Firebase to handle both Android and iOS as it has the capabilities of doing that. I am using ionic so would be using the firebase plugin.
Is it possible to send pus notifications from Azure Notifications Hub to iOS through firebase or does it have to only go through APNS?

Azure Notification Hubs sends Android Notifications through FCM and macOS/iOS notifications through the Apple Push Notification service (APNs).
Azure Notification Hubs has not been tested sending APNS notifications through Firebase Cloud Messaging (FCM); it's not a supported configuration.
If you don't mind me asking, what is it about FCM that makes you want to send Apple notifications through it? All that does is add an extra layer of complexity on top of something ANH already does quite well.

#AndySousa I answered your Azure Forums question on the same topic - copying the response here:
I'm trying to get a blog post published on this, but for Ionic 4 here's what I learned:
The Ionic team made a lot of changes to the framework plus released Capacitor, their alternative for Apache Cordova. Capacitor still supports Apache Cordova, but only a subset of the existing plugins. Ionic also built many common plugins into Capacitor, so you no longer ‘need’ Cordova plugins to deliver certain functionality to your app.
One example of this is the Capacitor Push Notifications plugin which adds support for registering for and processing push notifications to Capacitor. If you follow the procedure to create an Ionic 4 project, add the cordova-azure-notification-hubs plugin to it, and add the code that registers for and processes notifications like you did for Ionic 3 applications, you’ll find that your application registers successfully, but never ‘receives’ any notifications.
What’s happening is that the cordova-azure-notification-hubs plugin is properly managing the registration process with Azure Notification Hubs, but the Capacitor Push Notifications plugin intercepts all notifications that arrive on the device, circumventing the Azure Notification Hubs SDK.
This means that to automatically register for and receive notifications, your Ionic 4 application must use both plugins. The cordova-azure-notification-hubs plugin to manage automatic registration, and the Capacitor Push Notifications plugin to process them when they arrive. Special thanks to Matthew Podwysocki (Microsoft) and Mike Hartington (Ionic) for figuring this one out.
We created a sample application (https://github.com/Azure/azure-notificationhubs-samples/tree/master/Ionic/ionic-4) that shows how to use the plugin in an Ionic 4 app. The sample implements the same Ionic Provider for Azure Notification Hubs that manages registration, but adds additional code to use the Capacitor Push Notifications plugin to process received notifications. With that in place, it’s basically the same UI and logic as the Ionic 3 sample (updated for changes in Ionic 4).
The Capacitor Push plugin also supports a similar registration event listener you can use to grab the device push token and send it to your app backend for Azure Notification Hubs registration. Doing this eliminates the need to use the cordova-azure-notification-hubs plugin in your Capacitor application.
Note: The sample app I reference here is provided for educational purposes, we do not provide Ionic support.

Related

Xamarin and Push Notifications - Reason to use Azure Notification Hubs?

Good afternoon,
I apologize in advance, as I know this is subjective. But, I'd very much love the opinion of a Xamarin expert.
I'm building a mobile application for a client using Xamarin targeting Android and iOS devices. We have a .NET Web API back-end application that is consumed by a MVC web application (hosted in Azure), and now our Xamarin application. Our API needs to send basic push notifications (to iOS and Android) when certain things happen.
I've configured push notifications (also targeting Xamarin projects) in the past, but it has been a few years. That configuration included Azure Notification Hubs and GCM (the GCM piece was recently updated to Firebase - still in combination with Azure Notification Hubs). All of that is working just fine.
After reviewing push notifications again, it seems as though Firebase has become something of a Notification Hub itself, handling both iOS and Android applications. There is plenty of documentation on setting up push notifications in a variety of ways, using just Firebase for both iOS and Android, using Firebase with Azure, using just Azure for iOS, etc.
So, my question is.. If you are a seasoned Xamarin developer creating a new iOS and Android targeted application with a .NET backend, would you use Azure Notification Hubs? Based on my reading, it seems as though the simplest approach would be to utilize Firebase for both iOS and Android, leave out the Azure Notification Hub piece of it, and use our back-end to make a single POST request to the Google API (i.e. https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send based on their documentation at https://firebase.google.com/docs/cloud-messaging/send-message) to send a new push notification.
However, that doesn't sit very well with me considering that Microsoft is behind both Xamarin and Azure. My gut is telling me that I should be using Azure Notification Hubs. Could someone please provide some guidance? I feel like I'm not understanding something that's preventing me from being able to come to a good conclusion on my own.
Thanks,
Chandler
This seems to be a problem with the software architecture. Technically, notifications can be done for both Azure and IOS/Android notifications. But from user data statistics and future data service analysis, you need to consider whether the notification service you used before can continue to provide services for you. At the same time, if you are ready to abandon the previous use, you can slowly split some users to use the new notification service. From my personal point of view, this is the safest.

GCM to FCM migration ionic v1

I have an ionic v1 app. I've read and re-read the information about GCM to FCM migration, but I am still not 100% certain that my (unmigrated) app will still receive push notifications after April 11. I have migrated the server to FCM. I believe that the app should still work, but need it verified for certain.
Based from this link, you need to update your client code and migrate to FCM.
Existing deployed client-side apps receiving notifications will continue to work for the foreseeable future. But from mid-april, you:
won't be able to compile code using the old client-side APIs on a newer SDK/Google Play Services anymore
won't be able to call the GCM REST API to send messages anymore
To compile against the new SDK/Google Play Services, you will need to make changes to your client app to migrate to Firebase Cloud Messaging from GCM. This involves changes to the build.gradle, to AndroidManifest.xml and to your code, as described in Migrate a GCM Client App for Android to Firebase Cloud Messaging.
But aside from those changes, you don't need to get new tokens for all users. The existing tokens from GCM will continue to work.

push notifications ionic 2 for android

I need to configure push notifications for an Ionic 2 application for android devices.
I read here that in order to do that you need to login to Firebase console, create a project and so on...
So my question is, do I really need to log into Firebase to do this? I'm not using firebase in my app, so I don´t get why I need to create a project to get a SERVER_ID and SERVER_KEY. What if I delete that project in Firebase afterwards, then my push notifications will stop working?
Thanks
Yes, you do need an account to use Firebase Cloud Messaging because you'll need a key to send pushs.
You need the key to use device-to-device push via HTTP and you need a project to send notifications to a group or topics.
I don't think that there's a way to use push without creating an account in any service.
You don't need a Firebase account.
You can use azure notifications hub or amazon aws or google cloud service, ionic cloud, etc.
Any cloud services that provides a notification hub which is basically a server for receiving and redistributing to the registered parties to the specific platforms.
Please note that some of these are specifically mobile oriented meaning you wont have to write any server side code and others aren't.

How to create a topic in Firebase using Ionic 2 rc.0?

I would like to subscribe to certain topics in Firebase for my Ionic 2 app, so I want to know how to create them in Ionic 2. An example code for demonstration would be great.Thanks in advance.
There is no direct way to subscribe to topics using the Firebase Cloud Messaging for Web API.
However, you can use the GCM REST API to subscribe to the topic as described here: GCM: How do you subscribe a device to a topic?. Last time I checked, these subscriptions made in this way were delivered to the device correctly.
Also see my answer here: Is it possible to broadcast messages in a production PWA using FCM for Web without having a dedicated XMPP server?

Signal R Vs Push Notifications for real time applications like Chat

I want to create a chat application for ios, android and windows phones as well as it should work with browsers in the future. My search led me to using Signal R with Azure Mobile Services(AMS).
My questions:
1) SignalR uses Websockets under the hood. Is websocket supported in Android, IOS, windows phones and all mobile/desktop browsers??
2) If not, how will it effect using SignalR with AMS?
3) Or should I just use Push notifications supported in AMS?
4) Any sample app/code snippet you can share. Note that I will be using Xamarin for my app development.
5) Any advice you can give for same.
Azure Mobile Services has SignalR integrated, and Azure Mobile Services provide a SDK for client apps, I suppose it is provide out-of-the box
See
Real-time with ASP.NET SignalR and Azure Mobile .NET Backend
Master the Managed Azure Mobile Services Backend–Part Four
High value mobile backend capabilities included
You will find many capabilities included in Mobile Services and readily available for your Web API. Mobile push notifications, real-time notifications with SignalR (auto-scaled out), social auth for your consumer apps, offline data sync for occasionally connected scenarios, to name a few.
Samples:
https://github.com/gshackles/RealTimeGallery
Sample to help developers to implement Push Notification, through Azure Notification Hubs, in mobile applications.
Note:
Azure Mobile Service is based in WebAPI!
For that you want, you should not use only Push Notification because Push Notification in iOS could not be read by the application if the user ignore it, only in android or windows you can get and save it. Another thing that can be a problem is the fact if the app is running you should not show the push notification and you should show a pop up with the notification... and the push notification can have a delay from the Push Notification Service (Apple, GCM, WNS...). Push notification are a notification that something happened in the app when the user is not using it.
In my opinion you should use AMS+SignalR for realtime communication and then Push Notification for update the user then he not using the app.
Using SignalR is efficient to save yourself from hitting any push notification cap if you ant to limit your costs. But you'll need to either turn notifications on/off at the right time when the app becomes active or inactive, otherwise the app may go in the background and push notifications won't be sent.
You can use a pure push approach where notifications are shown when the app is inactive/in the background, and whenthe app is active, you simply intercept the notification in the app, consume it and cancel it so it doesn't get shown. I have written a blog post on this approach along with 3 samples in Github for iOS, Android and Windows Universal at http://www.ageofmobility.com/2014/10/06/azurechatr-building-a-cross-platform-chat-app-for-windows-ios-android/.

Resources