Locative is my go to app for Geofencing with XTension. Any geofencing app that supports HTML requests as actions can be used with the JSON Interface server but I have added some specific support for Locative that makes it simpler. In order to use the Locative specific features you must be running XTension version 8.9.2 (build 944) or later.
First you need to setup the JSON server and pass the port you select through your NAT router. The JSON Server page will describe how to set that up.
You’ll need a “TAG” in the JSON server for your locative devices. Only one tag is necessary for all your locative devices. You can use the default generated random string of characters or you can click on that entry in the list and change it to something easier to enter into your iPhone.
In the Locative app on your iPhone go to the settings page and enter an http request in the global http settings field. It should look something like this:
thats your dyndns or no ip address and don’t forget the port followed by the tag you created in the previous step and the last portion of the request is the app name “locative” leave the “POST/GET” button set to POST though GET will work just fine too POST is the default.
You can now do a “send test-request” from the button just below the Global HTTP settings and you should see the test logged to the XTension log if everything is working.
in Locative you can now create your geofences or import them from your account on the locative website.
You must override the default Location ID. Locative will generate a long uniqueID string there but you should change it to something that can be the unit address in XTension. Something “PeterHome” or “DaughterSchool”.
Turn on the “Trigger on arrival” and “Trigger on Departure” switches.
You can leave the POST fields blank since all the geofences you create will now use the global HTTP settings that we already setup.
REMEMBER TO CLICK THE SAVE BUTTON! and not just use the back arrow to go back to the list. If you just go back it will not save the changes you have just made and that is very frustrating. It seems to be my reflex to go back rather than click save so I mention it here so it won’t bite you.
Create a new unit in XTension assigned to your JSON interface.
It should be of device type “register”
Set the address to the same string you used as the Location ID in the step above “DaughterHome” or “JackOffice” or something similar.
There seems to be a bug in Locative as of this writing where it will sometimes resend you the previous geofence event after sending you the new one. What happens is that you get the exit event for your location ID and then immediately you get an enter event for it! As of build 8.9.2 I’ve built in a check for this and old duplicate events are ignored. They are written to the log as ignored so you can see if it is happening. In my testing so far this is successfully removing those and not blocking any real events.
The locative hit contains the timestamp that the phone realized you had entered or exited the geofence. Keep in mind that the system does not tell the app about a geofence change immediately as you cross the line. It can take from a few seconds to a few minutes to notice that it’s changed. Once it does notice it there can be a further delay as the network inits and tries to make the connection. XTension will take the timestamp from the event and conform the units last activity date to the time sent. If the network connection is particularly slow for some reason the event may be received at 10:23 but the last activity may now be set to 10:19.
Locative additionally sends the latitude and longitude of the crossing of the fence. I’m not yet sure how one would use this, perhaps to know the direction from which you left or arrived? I am currently inserting the data into unit properties in the XTension unit that can be retrieved in the ON or OFF script handling of the event.