Push notification documentation

Manuel Suárez6 years ago

Hello Anton, good afternoon, I would like to ask if there are any approximations for the publication of the documentation for the Push notifications?

Belami Albert6 years ago

Hello,

Any indication on the config file variables would be helpful.

Many thanks.

Anton Tananaev6 years ago

I have added documentation for push notifications:

https://www.traccar.org/documentation/notifications/

Belami Albert6 years ago

Thanks a lot !

Any way to send single notifications to each account ? (by token or else ?)

Anton Tananaev6 years ago

Do you mean send it manually? What kind of notification?

Belami Albert6 years ago

For example, to send a mail notification to a user, we type its email address in the email address field. When an event occurs , a mail is sent to this user in his mailbox.

To send notifications using firebase, we need to specify the user token so we can send him the notification to his own device.

BTW, we have are using our own custom app to communicate with traccar.

Thanks again for your help.

Anton Tananaev6 years ago

App token is automatically register when you use Traccar Manager app.

Belami Albert6 years ago

What if we use a custom app ? Anyway to communicate the device token to traccar ?

Anton Tananaev6 years ago

It's stored in user attributes. Just check Traccar Manager and web app source code.

Fergal Powell6 years ago

Is it possible to have push notifications on a my own custom application coming from my traccar server, using my own FCM server?

Belami Albert6 years ago

The mobile app stores the phone token in the user attributes (Check DB). You can make your custom app register tokens in the same field and have notifications sent to each user of you base. That's how we got it working.

If anyone has a better solutions please share :)

Fergal Powell6 years ago

Thank you so much Belami and Anton for your help, that technique is working great for me! I'm using cordova-plugin-firebase and Traccar api to insert a new token into the user attributes when a new token is created, similarly to the Traccar Web App.

window.FirebasePlugin.onTokenRefresh(function(token) {
        console.log("My new firebase token: " + token);
        if(!user['attributes']['notificationTokens'] || user['attributes']['notificationTokens'].indexOf(token) < 0){
            if(!user['attributes']['notificationTokens']){
                UpdateAppToken(token);
            } else {
                let tokens = user['attribute']['notificationTokens'] += ',' + token;
                UpdateAppToken(tokens);
            }
        }
    }, function(error) {
        console.error("New Firebase token error: " + error);
       }
);
Parth6 years ago

Hi

What can I do if I want to only update notificationTokens?

Currently, I manage from http://IP:PORT/api/users/id.
In this API we must to share name, email.
Without using this there is any API which only update notificationTokens.

Anton Tananaev6 years ago

Check what official web app does. It uses same API.