I want to subscribe to a FCM (Firebase Cloud Messaging) topic from the front end (web) of an Angular application.
From what I've learned from here and here, it looks like subscription to topics can't be done via web from the front end. The client should send a token and a topic to the server, then the server should request the subscription to FCM.
I'd like to know if there's a way I can securely subscribe to topics directly via web.
You can subscribe client app instances to any existing topic, or you can create a new topic. When you use the API to subscribe a client app to a new topic (one that does not already exist for your Firebase project), a new topic of that name is created in FCM and any client can subsequently subscribe to it.
fun sendMessage(title: String, content: String,topic: String) — This method is used to send Messages as Push Notifications to devices that are subscribed to a particular topic. Let's see how this method works internally. It uses HttpUrlConnection internally to trigger an API. (i.e https://fcm.googleapis.com/fcm/send).
The FCM JavaScript API lets you receive notification messages in web apps running in browsers that support the Push API. This includes the browser versions listed in this support matrix and Chrome extensions via the Push API. The FCM SDK is supported only in pages served over HTTPS.
yes it can be done client side
this.push.subscribe(
'your Topic',
() => {
console.log('success');
},
e => {
console.log('error:', e);
}
);
more information
https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md
https://ionicframework.com/docs/native/push
this is related your topic
https://forum.ionicframework.com/t/firebase-push-notification-topic-subscription/95523/6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With