CPPresenceService

@objc
public class CPPresenceService : NSObject, CPServiceProtocol

This class is used to manage presence services such as presence source publishing and presentity watching.

  • Undocumented

    Declaration

    Swift

    public var restClient: CPRestClientBase?
  • An application that needs notifications should implement a PresenceDelegate compliant class and set this member as an instance of that class.

    Declaration

    Swift

    @objc
    public var delegate: CPPresenceDelegate?
  • A subscription to watch a PresentityList will expire. Use this member variable to specify a custom duration in seconds. The default value is 86400 seconds, one day.

    Declaration

    Swift

    @objc
    public var subscriptionDuration: Int
  • Initializes presence service instance with given configuration.

    Declaration

    Swift

    public init(userInfo: CPUserInfo, info: CPServiceInfo)

    Parameters

    userInfo

    User Information.

    tag

    Name identifying the service. Used in logging.

    serviceApi

    Service API name used in building service URL.

ServiceProtocol methods

  • Delegate method to get a service’s information

    Declaration

    Swift

    public func serviceInfo() -> CPServiceInfo

    Return Value

    service information object with service type and preferences.

  • Delegate method to get a list of notfications the service expects

    Declaration

    Swift

    public func notifications() -> [String]

    Return Value

    list of notification names. These should match what is returned by subscribe() in completion callback.

  • Delegate method to subscribe for notifications from a remote channel

    Declaration

    Swift

    public func subscribe(channelID: String, completion: @escaping SubscribeCompletion)

    Parameters

    channelID

    The channel on which to subscribe for notifications.

    completion

    Code block to execute upon subscription completion.

  • Delegate method to unsubscribe for notifications

    Declaration

    Swift

    public func unsubscribe(channelID: String, completion: @escaping UnsubscribeCompletion)

    Parameters

    channelID

    The channel from which to unsubscribe for notifications.

    completion

    Code block to execute upon subscription completion.

  • Utility method for refreshing all PresentityList subscriptions that are near expiration. Typically an application will want to refresh a subscription before it expires. If a subscription will expire before the next period in which an application will attempt the refresh action, use the interval of the period as the expiringInSeconds value. Alternately, an application could periodically refresh any subscriptions that will expire within the next day, in this case use expiringInSeconds value of (24 * 60 * 60.0)

    Declaration

    Swift

    @objc
    public func refreshSubscriptions(expiringInSeconds: Double, completion: @escaping ErrorCompletionBlock)

    Parameters

    expiringInSeconds

    Number of seconds within which the subscription will expire.

    completion

    Code block to execute upon subscription refresh completion. The completion block will be called for any subscription that is refreshed. This means that it is possible that the completion block will not be called in the case that no subscription is refereshed

Presence source publishing

Presentity watching