java.lang.Object | |
↳ | com.salesforce.android.sos.api.SosAvailability |
API used for monitoring the SOS system for agent availability updates. Availability checks should usually follow this pattern:
addListener(Listener)
to add a listener object (typically an activity).startPolling(Context, String, String, String)
to start polling for availability
changes.onSosAvailabilityChange(Status)
to enable or disable
SOS-related functionality.removeListener(Listener)
(e.g.
in the activity's onDestroy()
method.)stopPolling()
if you no longer need to monitor SOS availability.
public class MyActivity extends Activity implements SosAvailability.Listener {
@Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Add ourselves as an availability listener.
SosAvailability.addListener(this);
// Update the UI based on the last known availability status, if any.
updateAvailability(SosAvailability.getStatus());
// Start polling to receive any change in the status.
if (!SosAvailability.isPolling()) {
SosAvailability.startPolling(this, organizationId, deploymentId, liveAgentPod);
}
}
@Override
public void onDestroy () {
super.onDestroy();
// Always makes sure to remove the listener.
SosAvailability.removeListener(this);
// Stop polling if appropriate. Don't do this if you want polling to continue in the
// background.
SosAvailability.stopPolling();
}
@Override
public void onSosAvailabilityChange (SosAvailability.Status status) {
updateAvailability(status);
}
private void updateAvailability (SosAvailability.Status status) {
// Update the UI to reflect the availability status here.
}
}
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
interface | SosAvailability.Listener | The Listener interface is used to receive updates about the SOS availability status. | |||||||||
enum | SosAvailability.Status | Enumerates the possible availability statuses for SOS. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
SosAvailability() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static void |
addListener(SosAvailability.Listener listener)
Adds a Listener instance to listen for availability status changes.
| ||||||||||
static SosAvailability.Status |
getStatus()
Return the result of the most recent poll request.
| ||||||||||
static boolean |
isPolling()
Checks if the SDK is current polling for availability status.
| ||||||||||
static void |
removeListener(SosAvailability.Listener listener)
Removes a previously added Listener instance.
| ||||||||||
static void |
startPolling(Context context, String organizationId, String deploymentId, String liveAgentPod)
Starts polling the availability endpoint with the given information.
| ||||||||||
static void |
stopPolling()
Stops the polling explicitly.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Adds a Listener instance to listen for availability status changes. Listeners should be removed when they no longer need to respond to availability changes.
listener | The Listener instance to add. |
---|
Return the result of the most recent poll request.
Checks if the SDK is current polling for availability status. This is true in between calls
to startPolling(Context, String, String, String)
and stopPolling()
, and false
otherwise.
Removes a previously added Listener instance.
listener | The listener to remove. |
---|
Starts polling the availability endpoint with the given information. This method must be called
in order to kickstart the process which will trigger the SosAvailability.Listener
instances when the availability status of the SOS system changes. This method should only be
called once; multiple calls will cancel and restart any in-progress availability checks.
context | A context to use for polling. |
---|---|
organizationId | The Salesforce Organization ID for your company. |
deploymentId | The Salesforce Deployment ID identifying the deployment queue to check. |
liveAgentPod | The live agent server to use. |
Stops the polling explicitly. This should be called when you no longer need to know about the SOS availability status in order to release resources associated with the polling mechanism. Note that polling will be stopped automatically when a session is started. This method is idempotent.