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

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?

Related

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

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.

Does Firebase create a topic when I subscribe to a non existing one?

I started working with Firebase in order to simplify the use of Push Notifications of my app. Searching around the Docs I found the possibility to send a notification to a group of devices through a topic which the devices are subscribed to.
My doubt comes out here. When I subscribe the devices (using firebaseToken) to the topic I want to use, does this topic creates implicitly if it's not created?
If it doesn't, when and how can I create a topic to use it later?
I'm using Firebase Cloud Store an Firebase Messaging.
You don't need to create a topic in order to use topic messaging. It just works the way you expect as long as the server and clients all agree on the name of the topic.
Firebase Cloud Messaging isn't related to Cloud Firestore in any way, other than that they are both Firebase products and are seen together in documentation and the console.

Does mongodb-stitch support push notification for ionic?

I am following this tutorial in mongodb stitch. https://docs.mongodb.com/stitch/tutorials/push-notifications/
However it looks like this one is for android app only. I am developing an ionic app using mongodb stitch. Do you think mongodb stitch supports push notification for my ionic 3 app?
Following your link reveals that MongoDB cloud services actually do not provide a complete standalone solution for push notifications. They suggest to setup Firebase Cloud Messaging (FCM) for this and you can configure stitch to trigger a push notification via FCM. You would need to setup firebase (free tier) for that and stitch separately. I do not know if that scales well and is at the time of my answer a big downside of MongoDB services.
Yeah, they just provide an example via Android, but I think using it on client side is very straight forward. The most part is configuring the backends.
I hope that helps.

Receive Custom FCM In Unity

I integrated Firebase Cloud Messaging with Unity successfully and I can receive usual messages when I send them from Firebase Console, but I need some extra things.
1 - How can I send my notification as a URL? I mean I want that when user touches the notification it opens the URL that I put in the value in FireBase Console.
2 - How I can send and show a picture and a custom icon in the notification?
Unfortunately, I can't find anything on the internet and official documents confused me.
Is there any way to gain these request only with FireBase SDK?
Thank you.
You have to handle all the messages from FCM manually to get all those features you are looking for. I mean you got the general implementation all the stuff, but you need the unique one. All the notification display settings and notification click handlers have to be implemented on the Android native side.
Probably you will find some interesting FCM asset in the Asset Store with nice notifications customization, not sure. But I would recommend you to surf the Asset Store, maybe there will be some useful packages.

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.

Resources