FireBase Push Notifications

NanaYaw3 years ago

Are there any possible ways i can check if the traccar server is really sending me push notifications using the firebase key.
Ive specified in the config in the traccar.xml with the firebase server keys , and ive also set up firebase push on the iOS app.

config

is there any possible way i can verify if push notifications are been sent by watching the logs or anywhere?

Anton Tananaev3 years ago

There's logging for errors, so you can try changing the key to see if you get an error.

NanaYaw3 years ago

okay im trying that now!

Anton Tananaev3 years ago

I haven't tried it myself, so I'm not sure it will actually trigger an error in the code.

NanaYaw3 years ago

It did trigger an error and i saw it in the logs, that means it is sends push notifications using firebase.
However im not receiving the notifications in my custom IOS app, even though im able to send a receive push notifications from the firebase console to my custom app.
I am digging into why my custom app is not receiving notifications from traccar.

Anton Tananaev3 years ago

Have you checked user attributes? You have the Firebase token there?

NanaYaw3 years ago

i checked the user attributes and i see a field notificationTokens see image link below;

Link name

But i don't remember creating that attributes and the key in there does not even much the server notification key i got from firebase.
Can you elaborate more about that key , may be thats the cause.

Anton Tananaev3 years ago

It's a device token. It shouldn't match the server key. You need to make sure it's a valid token for your firebase account. Try sending notification with it manually.

NanaYaw3 years ago

i updated the user attributes notification token with the iOS app device token, and beautifully i got my first push notification from traccer.
i was wondering if there is an API to register the device token , i see a field in the create user endpoint named "token" , is that where i can update the notificationToken ?

Anton Tananaev3 years ago

You should use standard user endpoint to set notificationToken attribute.

NanaYaw3 years ago

okay so you mean in the standard user endpoint , i can set notificationToken attribute as

 attributes": {
      notificationToken : "sometoken"
}
Anton Tananaev3 years ago

Yes, something like that. Note that the key is actually notificationTokens not notificationToken. Because each user can have multiple devices.

NanaYaw3 years ago

okay.

NanaYaw3 years ago

Does it also mean i can pass more than one token to the notificationTokens attribute , like the example below ?

attributes": {
      notificationTokens : "sometoken1 ", "sometoken2"
}
Anton Tananaev3 years ago

Obviously it has to be a valid JSON. You can pass tokens separated by a space or a comma.