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.
-
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
-
Create a presence source on the server.
Declaration
Swift
@objc public func createPresenceSource(activity: PresenceActivity, completion: @escaping CreatePresenceSourceCompletionBlock)
Parameters
activity
Presence activity object representing the activity of the presentity
completion
Code block to call after the create operation completes.
-
Update a presence source on the server.
Declaration
Swift
@objc public func updatePresenceSource(source: CPPresenceSource, activity: PresenceActivity, completion: @escaping CreatePresenceSourceCompletionBlock)
Parameters
source
Current presence source.
activity
Presence activity object representing the activity of the presentity
completion
Code block to call after the update operation completes.
-
Fetch presence source associated with the local client
Declaration
Swift
@objc public func fetchPresenceSource(completion: @escaping FetchPresenceSourceCompletionBlock)
Parameters
completion
Code block to execute upon fetch compeletion.
-
Fetch presence source matching the passed in source
Declaration
Swift
@objc public func fetchPresenceSource(source: CPPresenceSource, completion: @escaping FetchPresenceSourceCompletionBlock)
Parameters
source
Presence source to match against when fetching.
completion
Code block to execute upon fetch compeletion.
-
Delete a presence source from the server.
Declaration
Swift
@objc public func deletePresenceSource(source: CPPresenceSource, completion: @escaping DeleteCompletionBlock)
Parameters
source
Presence source object representing the source to delete from the server.
completion
Code block to execute upon delete completion.
-
Create a presentity list on the server.
Declaration
Swift
@objc public func createPresentityList(name: String, presentities: [String], completion: @escaping CreatePresentityListCompletionBlock)
Parameters
name
Presentity list name.
presentities
Array of desired presentities to monitor.
completion
Code block to call after the create operation completes.
-
Fetch an array of all PresentityLists.
Declaration
Swift
@objc public func fetchAllPresentityLists(completion: @escaping FetchPresentityListsCompletionBlock)
Parameters
compeletion
Code block to execute upon fetch compeletion.
-
Fetch PresentityList from backend that matches the passed in PresentityList.
Declaration
Swift
@objc public func fetchPresentityList(presentityList: CPPresentityList, completion: @escaping FetchPresentityListCompletionBlock)
Parameters
presentityList
PresentityList to match against when fetching.
compeletion
Code block to execute upon fetch compeletion.
-
Delete PresentityList from backend that matches the passed in PresentityList.
Declaration
Swift
@objc public func deletePresentityList(presentityList: CPPresentityList, completion: @escaping DeleteCompletionBlock)
Parameters
presentityList
PresentityList to match against when deleting.
compeletion
Code block to execute upon delete compeletion.