Firebase push notification - by topic

Blueoceana year 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 Tananaeva year ago

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

Blueoceana year ago

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

Anton Tananaeva year ago

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

Blueoceana year 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 Tananaeva year ago

I would recommend reading the official documentation for the SDK.

Blueoceana year ago

Thanks Anton.

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