HI Anton Tananaev!
So, I am sorry for bothering you again with the same issue.
So clearly mention that if we have to manually attache a device with a fence which Api we need, as far I have studied we need a linker Api that will link between the device and geofence:
{{baseUrl}}/permissions
Body : {"deviceId": 8, "geofenceId": 376}
the response is 204 here ,
I fetch the device 8 and here it is
{{baseUrl}}/devices?id=8
The response :
{
"id": 8,
"attributes": {},
"groupId": 0,
"name": "RF-V34/1403152554",
"uniqueId": "1403152554",
"status": "offline",
"lastUpdate": "2023-01-11T10:44:07.806+00:00",
"positionId": 27886,
"geofenceIds": null,
"phone": "2365",
"model": "RF-V34",
"contact": null,
"category": "tracker",
"disabled": false,
"expirationTime": null
}
why its not updating when I will do like this using postman.
Please guide me if I am doing anything wrong or can you tell me how to do this task.
Because you're looking in the wrong place. The field in the devices model is not for all linked geofences, but only the ones that the device is currently in.
Thanks for the Response Anton Tananaev,
So the device will update its Geofenceid via linker api only if the device is within the fence ?
The API does not update that field.
How is the field updated then?
Automatically once the geofence is linked.
OK Got it thanks for the Replies Anton, Have a nice weekend :)
HI Anton Tananaev,
I am sorry I am bothering you again and again ,
My logic works on the basis of the GeofenceIDs attribute in the device object that traccar update by itself after permission API is called.
can you please help me here
Thank you .
Best Regards,
Usman Khan
How are you checking if they are connected or not?
I see if the Device object in the redux get Updated with the geofenceIds
And also fetch the device in the postman but I do not see any Geofenceids
As I said previously, it's NOT the right place to check.
Then How should I know if the device is connected or not?
Sometimes it works as I call the permission Api and the Redux is updated
But sometime it does not work
You can call something like this:
GET /api/geofences?deviceId=X
This will return all linked geofences, assuming the user has access to them too.
Alright , So I am doing in such a way that when the user draw a geofence on the map it detects the devices under that drawn fence which are not connected to any fence then we need to connect all those device to that geofence. It can be 1 - 1000 or more devices ,
But I got what you said and I'll research on that.
Thanks for your time :)