Send Push Notification to only Registered Users' Geofence

Sumit7 years ago

I want to send push notification users' mobile devices. I made firebase table to store firebase_token and userId (e.g. firebase_token). And I linked the userId with the geofenceId in a separate table (let's say user_geofence).

When geofenceEnter or geofenceExit event occurs, I want to send only those firebase tokens which are linked with the user's created geofence.
I am not getting in the code where I have to put the code.

I have tested it out by sending manually geofenceId and match the geofenceId in user_geofence table to get the user and finally I got firebaseTokens in the firebase_token table by matching the userId.

abyss7 years ago

How do you determine when to send push notification?

If you use event forwarding, it is already implemented and will be available in next release. The list of users (who to notify) is forwarded with every event.

Sumit7 years ago

I only want to notify when geofence events occur. Is event forwarding made for geofence? Can you tell me where event forwarding is implemented? It may be help my problem.

abyss7 years ago

Event forwarding works for all events. You can filter what you want.

Sumit7 years ago

Did you get my point what I want to do?

abyss7 years ago

I think so. You want to send pushes about enter/exit a geofence only to users who have access (link) to the geofence. It is how traccar works out of the box (with other transports: email/sms)

You can start digging from here https://github.com/traccar/traccar/blob/master/src/org/traccar/database/NotificationManager.java#L114

Sumit7 years ago

Okay, thanks.
Suppose there are three users say A,B,C. And there is one device which is linked with these three users say D. And these three users have their own geofences. So when device is enter anyone of the geofences of the users, then push notification will be send to only that user's token what he/she has the geofence.

If device enter user A geofence then who are logged in with user A account, the push notifications will be received on the A's screen devices.

That's exactly I want.

abyss7 years ago

Want to note that geofences also must be linked to the device D. Actually everything is described in documentation.
And you can test yourself how it works with emails for example.

Sumit7 years ago

Yes the device is linked with all the geofences too.
Okay, thank you.

Sumit7 years ago

I am getting this Query not provided: database.selectTopPositions. And I have put the query in the default.xml file too.

jaimzj7 years ago

Sumit, are you using event forwarder? and the URL that event forwarder is pointed which language/platform is it written in.

If its PHP I have some working samples.