How can I use push notifications on Android?

Juan Márquez6 years ago

Hi Anton and guys,

I would like to know if is there any way to receive the notifications from Traccar, but as a push notification on the phone. I have enabled some notifications and alarms for my device, but I want to receive them in my phone even if I am not watching the app.

Thanks.

Anton Tananaev6 years ago

That's what Firebase push notifications are for.

Juan Márquez6 years ago

Hi Anton, this what I have done:

  • I have built a new version of Traccar Manager in Android Studio 3.3
  • I set it up and synchronized with a firebase project
  • I changed the package name of the app
  • I added these lines to traccar.xml:
<entry key='notificator.types'>web,mail,firebase</entry>
<entry key='notificator.firebase.key'>[my_firebase_project_key]</entry>
  • I restarted Traccar service
  • I enabled alarm notifications for my user in Traccar
  • I use the SOS button in one the android phones I added
  • I received the SOS alert via web, and email, but not as a push notification in the rebuilt firebase-registered installed app in my android phone

Is there anything I have missed?

Thanks

Anton Tananaev6 years ago

Check firebase token in user attributes.

Juan Márquez6 years ago

What do you mean?
Do I have to add an attribute to a user in order to get notifications through firebase?
how to do that?

Anton Tananaev6 years ago

Traccar Manager does it automatically, but you should check if it happened.

Juan Márquez6 years ago

It worked fine now.
It added a notifications Token attribute to my user and i am now receiving push notifications on my app.

Thanks so much.

Przemyslaw5 years ago

@Juan Márquez Hi, Can You share step by step what You do to enable notifications? How Do You build new Traccar Manager in Android studio? How do You synchronize it with Firebase platform? How do You change name of that app?