Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229600

Firebase Push Notification Topic Subscription

$
0
0

I have the following code for push notifications using ionic cloud and Firebase Cloud Messaging.

let topic = "topics/" + this.user.userRole + "/" + this.user.location;
                    console.log("TOPIC: ", topic);
                    const options:PushOptions = {
                        android: {
                            senderID: "xxxxx",
                            sound: true,
                            vibrate: true,
                            //topics: [topic]
                        },
                        ios: {
                            alert: "true",
                            badge: false,
                            sound: "true"
                        },
                        windows: {}
                    };

It works, but as soon as I try to subscribe to a specific topic, then the app crashes when running from android.

When I use subscribe, in the manner below:

pushObject.on('registration').subscribe((data:any) => {
                        console.log("device registered -> ", data);
                        this.saveToken(data.registrationId);
                        let topic = "topics/" + this.user.userRole + "/" + this.user.location;
                        pushObject.subscribe(topic).then((res:any) => {
                            console.log("subscribed to topic: ", res);
                        });
                    });

Again, nothing happens and I'm not receiving any information showing I was able ot subscribe to a topic.

How do I accomplish topic subscription?


Viewing all articles
Browse latest Browse all 229600

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>