Registration
Developer Registration
In order to access the LocalSocial cloud service you must first register as a developer. The developer web-site
allows you to create new applications and view data related to your current applications (for example you can
view the number of downloads or view graphs of various analytical data for your applications)
The developer registration link is here.
Application Registration
As a developer, you can register a new application. To register an application you need to supply 2 pieces
of information, an application name (for example, Dowser) and namespace (this value must be unique
, for simplicity you should probably use something like the package nmae of your demo, for example dowser uses
com.localsocial.dowser).
Once the application has been registered, you can view the
application details. When you come to implement your first application you will need to supply the Consumer Key/ Secret
and the application name to the LocalSocial Library.
The application registration link is here.
Apis
How to use the APIs
Once you have registered a new application (and have noted your Consumer Key/Secret), you can now start using
the Java Android library.
Authorisation
In order to authorise an instance of an application running a on a device, a developer must provide some initial
data to configure LocalSocial. This data is available on the developer application details page.
Initial Configuration
The following code creates an instance of com.localsocial.config.SimpleAppConfiguration.
It sets :
Once the configuration has been created, we then call com.localsocial.LocalSocialFactory.setDefaultConfig,
to configure the default LocalSocial instance.
OAuth Authorisation
Once the LocalSocialFactory class has been properly configured then we can use
LocalSocialFactory.getLocalSocial() to get the default LocalSocial instance. This
LocalSocial instance is then used to create an AccessToken. The following code sample illustrates this authorisation
process.
Proximity API
LocalSocial exposes its proximity information through the com.localsocial.Neighbourhood.
Once you have created a LocalSocial and authorised it, you can then get an instance of the Neighbourhood.
Neighbourhood
In order to discover the devices that are in your vicinity, you need to register a neighbourhood observer.
Once registered, LocalSocial will inform your observer when a proximity event occurs (assuming you are
scanning the neighbourhood).
The following code sample shows how to register a
com.localsocial.proximity.observers.NeighbourhoodObserver that logs whenever a device
comes into range.
TagRemote
An instance of com.localsocial.remote.TagRemote is required to access the
LocalSocial Tag API.
For example, the following code illustrates how to get a TagRemote Object instance.
Tag CRUD
CRUD stands for Create, Read, Update and Delete..
The following code samples show how to implement the Tag CRUD methods.
Create a Tag
Use the following code to create a Tag on the current device.
Read a Tag
Use the following code to read a Tag set on the current device.
Update a Tag
Use the following code to update a Tag set on the current device.
Delete a Tag
Use the following code to delete a Tag.
Tagging Discovered Devices
The previous samples all illustrate how to tag the current device. Tagging a discovered device is only more difficult
in that it should be performed in a threaded environment (you can call any of the TagRemote methods directly but
since these methods involve remote calls you should do them in a separate thread).
The following code shows how to tag discovered devices with a timestamp that shows when they were last seen by
this device.
Client Assets
JavaDocs
The javadocs for the LocalSocial library are available here, you should probably
read them before creating your first application. (Please note that these APIs are subject to change).
Android
As already noted the latest version of the LocalSocial jar for android is available
here.
The current android dependencies are :
- scribe : Simple OAuth library for Java.
J2ME
We are currently working on the latest version of J2ME library.