Esri's Geotrigger Service is replacing Geoloqi! Learn More | FAQ

The Titanium module is no longer supported. Please see our blog post for more info.

Geoloqi Titanium Module Documentation

Getting Started

You will need to download the Geoloqi module from Github. Once you have downloaded the module follow the guide on the Appcelerator Documentation on how to install a module.

If you haven't already signed up for a Geoloqi developer account you should sign up now.

Sign Up Download the Module

Create a Geoloqi application

Once you have the module installed you will need to create a new Geoloqi application. Or you can use a client_id key from an existing app.

Get Keys

Configuring the module

At the top of your app.js file add the following line.

var geoloqi = require("ti.geoloqi");

This will make the Geoloqi modele accessable in your code. Now you need to initialize the module using the geoloqi.init() method. For security reasons, you should leave clientSecret empty.

geoloqi.init({
clientId: "Your application client_id",
clientSecret: "",
trackingProfile: "PASSIVE",
},{
onSuccess: function(){
  Ti.API.info("Tracking Profile: " + geoloqi.tracker.getProfile());
  Ti.API.info("Access Token: " + geoloqi.session.getAccessToken());
  Ti.API.info("User ID: " + geoloqi.session.getUserId());
  Ti.API.info("Username: " + geoloqi.session.getUsername());
  Ti.API.info("Anonymous?: " + geoloqi.session.isAnonymous());
},
onFailure: function(){
  Ti.API.error("Geoloqi Config Failed");
}
});

The geoloqi.init(); call will create a anonymous user account ont the Geoloqi API to store location information in or load a previous session if the app has launched before. It will also start the tracking the users location with the specified tracking profile.

Because geoloqi.init(); runs ansynchronously (Creating a new anonymous user) You should put all Geoloqi specific code in the onSuccess callback.

Once the geoloqi module has sucessfully initialized you can call a number of helper methods to get information about the state of the module.

Helper Methods
  • geoloqi.tracker.getProfile() return the current tracking profile.
  • geoloqi.session.getAccessToken() return the current users access token. This is helpful if you want to create your own login system and store the users access token yourself.
  • geoloqi.session.getUserId() return the userId of the current user.
  • geoloqi.session.getUsername() return the username of the currently logged in user
  • geoloqi.session.isAnonymous() returns true if the user was created anonymously.

iOS Push Notifciations

To setup push notifications for iOS please follow our iOS push notification guide.

Once you have uploaded your P12 Certificates to Geoloqi you should add this code block to the onSuccess callback of geoloqi.init();

Ti.Network.registerForPushNotifications({
  types:[
    Titanium.Network.NOTIFICATION_TYPE_ALERT
  ],
  callback: function(data){
    geoloqi.iOS.handlePush(data);
  },
  success:function(data){
    geoloqi.iOS.registerDeviceToken(data.deviceToken);
  },
  error: function(data){
    Ti.API.error("Could Not Register For Push" + data.error + data.type);
  }
});

This code instructs Titanium to let Geoloqi handle push notifications for your applicaiton.

Android Push Notifications

To setup push notifications for Android please follow our Android Push Notification Guide.

Once you have authorized your account, pass pushAccount and pushIcon parameters to the geoloqi.init(); configuration. For security reasons, you should leave clientSecret blank.

geoloqi.init({
  clientId: "Your clientId",
  clientSecret: "",
  trackingProfile: "PASSIVE",
  pushAccount: "[mailto:[email protected]",]([email protected]",)
  pushIcon: "push_icon"
}, callbacks)

Next open up your application's tiapp.xml file and copy and paste the below xml into the android block and replace, com.geoloqi.example with your application id.

<manifest>
  <permission
      android:name="com.geoloqi.example.permission.C2D_MESSAGE"
      android:protectionLevel="signature" />
  <uses-permission android:name="com.geoloqi.example.permission.C2D_MESSAGE" />
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

  <application>
      <receiver
          android:name="com.geoloqi.android.sdk.receiver.LQDeviceMessagingReceiver"
          android:permission="com.google.android.c2dm.permission.SEND">
          <intent-filter>
              <action android:name="com.google.android.c2dm.intent.RECEIVE" />
              <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
              <category android:name="com.geoloqi.example" />
          </intent-filter>
      </receiver>
  </application>
</manifest>

Tracking Profiles

The Geoloqi module uses several differnet "tracking profiles" to determine the behavior of the how to check and upload location data to Geoloqi. They are all designed around specific use cases and goals devleopers may need to accomplish.

Tracking Profiles
  • Adaptive: Use as little battery life as possible while still gathering the needed data.
  • Realtime: Send accurate location data to the server as fast as possible.
  • Logging: Record accurate logs of a trip, even when no network connection is present.
  • Off: No location services are used. The app will not receive location updates and location will not be tracked.
Changing profiles

If you need to change profiles as a part of your applicaiton to can do so like this.

geoloqi.tracker.setProfile("REALTIME");

You can pass a string (uppercase) of the profile you would like to use. REALTIME, PASSIVE, LOGGING and OFF are accepted.

Get the current profile

If you need to read the curent profile you can use.

geoloqi.tracker.getProfile();

User Authentication

If you want to allow users to create and authenticate against a Geoloqi account, you can do so like this.

Creating an anonymous user
params = {
  key: 'unique_identifier', // optional
  layerIds: ['xxx', 'yyy'], // optional
  groupTokens: ['abcdefg'] // optional
}

geoloqi.createUser(params, {
  onSuccess: function(data) {
    Ti.API.info(data);
  },
  onFailure: function(data) {
    Ti.API.error(data);
  }
});
Creating a named user
params = {
  username: 'loqi',
  password: 'secret',
  layerIds: ['xxx', 'yyy'], // optional
  groupTokens: ['abcdefg'] // optional
}

geoloqi.createUser(params, {
  onSuccess: function(data) {
    Ti.API.info(data);
  },
  onFailure: function(data) {
    Ti.API.error(data);
  }
});
Authenticating a user
geoloqi.authenticateUser('loqi', 'secret', {
  onSuccess: function(data) {
    Ti.API.info(data);
  },
  onFailure: function(data) {
    Ti.API.error(data);
  }
});

Making API Requests

Once the module is initialized you can make requests to the Geoloqi API. All requests are made in the context of the user.

Making GET Requests

The method signature for making GET requests if geoloqi.session.getRequest("method", params, callbacks). method is a method of the Geoloqi API such as "account/profile". The params object will be encoded as a query string before sending to the API. the callback object has 2 parameters onSuccess(response) and onFailure(response) which

Get the current users profile
geoloqi.session.getRequest("account/profile", {}, {
  onSuccess: function(data){
    Ti.API.info(data);
  },
  onFailure: function(data){
    Ti.API.error(data);
  }
});
Making POST requests

The method signature for making POST requests is geoloqi.session.postRequest("method", params, callbacks). method is a method of the Geoloqi API such as "trigger/create". The params object will be sent to the API as JSON. The callback object has 2 parameters onSuccess(response) and onFailure(response) which

Creating a geotrigger
geoloqi.session.postRequest("trigger/create", {
  "type": "message",
  "text": "Welcome to Powells Books",
  "latitude": 45.523334,
  "longitude": -122.681612,
  "radius": 300
  }, {
  onSuccess: function(data){
    Ti.API.info(data);
  },
  onFailure: function(data){
    Ti.API.error(data);
  }
});

Sample Deals App

Download the sample DinoDeals app to see how you can use Geoloqi to deliver relevant local deals to your users.

Method Reference

Geoloqi Module

init(object params, object callback)

This method is used to initialize the Geoloqi module.

Parameters
  • clientId: string Geoloqi API Key
  • clientSecret: string Geoloqi API Secret. We strongly recommend you leave this blank for security reasons
  • trackingProfile: string One of: "OFF", "ROUGH", "ADAPTIVE", "REALTIME", "LOGGING"
  • lowBatteryTracking: boolean Allow tracking when batteries are low?
  • vibrate: boolean Vibrate when receiving push notifications?
  • pushSender: string Used for Google Cloud Messaging on Android
  • pushIcon: string Used to set the icon used for push notifications on Android

When geoloqi.init() is called, an anonymous user account will be created automatically. If you would like to give the anonymous user a unique key, subscribe to layers, or join groups, you may provide the following optional parameters:

  • key: string A unique identifier for the user. Repeated calls with the same key will not create a new account and will instead use the existing account's access token.
  • layerIds: string[] array of layers to subscribe the new user to.
  • groupTokens: string[] array of groups to make the new user a member of.

createUser(object params, object callback)

Make a request to the Geoloqi API to create a new user.

Parameters
  • username: string Username or email is required.
  • email: string Username or email is required.
  • password: string (optional) If provided, allows the user to log back in via oauth.
  • layerIds: string[] (optional) array of layers to subscribe the new user to.
  • groupTokens: string[] (optional) array of groups to make the new user a member of.
  • extra: object A hash of keys and values to store along with the user.

authenticateUser(string username, string password, object callback)

Authenticate a user.

getSession()

Returns the Session object.

getTracker()

Returns the Tracker object.

setDebug(boolean isDebug)

Enable or disable debug logging.

isLowBatteryTrackingEnabled()

Returns a boolean indicating whether or not the tracking service will be allowed to run while device reports low battery.

enableLowBatteryTracking()

Enable tracking under low battery conditions.

disableLowBatteryTracking()

Disable tracking under low battery conditions.

Session Object

getAccessToken()

Get the access token for the currently authenticated user.

getUserId()

Get the user ID for the currently authenticated user.

getUsername()

Get the username for the currently authenticated user.

isAnonymous()

Determine if the session is currently configured with an anonymous user.

getRequest(string path, object params, object callback)

Send a get request to the Geoloqi API.

Parameters
  • path: The path to the API endpoint you wish to query.
  • params: Get paramters to send along with the request.

postRequest(string path, object params, object callback)

Send a post request to the Geoloqi API.

Parameters
  • path: The path to the API endpoint you wish to query.
  • params: Get paramters to send along with the request.

Tracker Object

getProfile()

Get the current tracking profile.

setProfile(string profile)

Request that the tracker switch to a different profile ("OFF", "ROUGH", "ADAPTIVE", "REALTIME", "LOGGING").

getStatus()

Get the current tracker status ("LIVE", "QUEUEING", or "NOTTRACKING").

getDateOfLastLocationUpdate()

Returns the date and time of the last location update in yyyy-MM-dd'T'HH:mm:ssZ format.

getDateOfLastSyncedLocationUpdate()

Returns the date and time of the last synced location update in yyyy-MM-dd'T'HH:mm:ssZ format.