CloudServices/Presence: Difference between revisions

Line 191: Line 191:
=== For App Developers ===
=== For App Developers ===


An app developer wishes to get presence information, the following can be addd to the app manifest:
Using presence in you application is done by:
 
# including extra information in your app manifest
# registering your app in the Presence service to receive notifications
# Decide if you want to use the stream API or to get notified via a webhook
# add a Presence doorhanger into your application so user can grant you access to their Presence info
 
 
==== Changes to the app manifest ====
 
An app developer wishes to get presence information, the following can be added to the app manifest:


     {
     {
Line 207: Line 217:
to the app.
to the app.


The application developer must register their application separately with Mozilla Presence and set a "Webhook URL"
==== Register the app in Mozilla Presence ====
that will be called with presence updates for users that look like the following:
 
The application developer must register their application separately with Mozilla Presence.
 
XXX define the registering API here
 
 
==== WebHook ====
 
 
It may optionally set a "Webhook URL" that will be called with presence updates for users that look  
like the following:
 


     POST /some/webhook/callback
     POST /some/webhook/callback
Line 218: Line 239:
         ["UID4828382", "online"]
         ["UID4828382", "online"]
     ]}
     ]}
In case the WebHook was not set by the application, updates have to be requested by using the
stream API, as explained in the next section.
==== Stream ====
When the application is registered, it gets back a unique application id <appid>.
This <appid> can be used to get a stream of presence updates by calling "GET <appid>/presence.json"
This will return a stream of presence updates for usersthat look like the following:
  GET <appid>/presence.json
 
  {[
      ["UID2949293", "away"],
      ["UID4823888", "online"],
      ["UID482838", "offline"],
      ["UID4828382", "online"]
  ]}
The application can consume the resulting stream for as long as is practical. The Presence server will
hold the connection open indefinitely,
barring server-side error, excessive client-side lag, network hiccups, routine
server maintenance or duplicate logins.
==== Setting up a doorhanger ====


When the user grants access, your application will get a unique ID that you should associate with the user record
When the user grants access, your application will get a unique ID that you should associate with the user record
Confirmed users
927

edits