Firebase push notification - by topic

Blueocean2 years ago

Dear All

Happy new year !

In firebase cloud messaging we can send messages to "device tokens" or to "topics".

(ref : https://firebase.google.com/docs/cloud-messaging/android/topic-messaging).

Can you please tell if firebase push "by topics" supported in the traccar server, if yes please share the pointers.

If not supported please tell which template or source code files that i should customise.

Thanks in advance

Anton Tananaev2 years ago

It's not supported because it's not relevant in case of Traccar.

Blueocean2 years ago

Can anyone please suggest which file should i modify to the code to send firebase push notification to a topic. Thanks

Anton Tananaev2 years ago

Have you tried searching for "firebase" in the source code?

Blueocean2 years ago

Thanks Anton. I found the code below, hope this is the right one. Any pointers of which method should i call to "send to topics" on the object "MulticastMessage.builder()"

MulticastMessage message = MulticastMessage.builder()
                    .setNotification(com.google.firebase.messaging.Notification.builder()
                            .setTitle(shortMessage.getSubject())
                            .setBody(shortMessage.getBody())
                            .build())
                    .setAndroidConfig(AndroidConfig.builder()
                            .setNotification(AndroidNotification.builder()
                                    .setSound("default")
                                    .build())
                            .build())
                    .setApnsConfig(ApnsConfig.builder()
                            .setAps(Aps.builder()
                                    .setSound("default")
                                    .build())
                            .build())
                    .addAllTokens(registrationTokens)
                    .putData("eventId", String.valueOf(event.getId()))
                    .build();
Anton Tananaev2 years ago

I would recommend reading the official documentation for the SDK.

Blueocean2 years ago

Thanks Anton.

If anyone else had implemented sending firebase message to "topics" please reply.