Utility Methods API for Swift Native SDK
The methods on this page are utility methods that don't fit into other categories.
Disconnect
Call the disconnect
method to stops the subscriptions in progress.
Methods
To disconnect
the data you can use the following methods in Swift SDK.
func disconnect( )
Sample code
Reconnect
Call the reconnect
method to force the SDK to try and reach out PubNub.
Method(s)
To reconnect
the data you can use the following method(s) in Swift SDK.
func reconnect(at timetoken: Timetoken? = nil)
* required
Parameter | Description |
---|---|
at * Type: Timetoken Default: n/a | The timetoken to reconnect the subscribe at. |
Sample code
Time
This function will return a 17 digit precision Unix epoch.
Algorithm constructing the timetoken
timetoken = (Unix epoch time in seconds) * 1_000_000_000
Example of creating a timetoken for a specific time and date:
// 08/19/2013 @ 9:20pm in UTC = 1376961606
timetoken = 1376961606 * 1_000_000_000
timetoken = 1376961606000000000
Method(s)
To fetch Time
you can use the following method(s) in Swift SDK:
func time(
custom requestConfig: PubNub.RequestConfiguration = PubNub.RequestConfiguration(),
completion: ((Result<Timetoken, Error>) -> Void)?
)
* required
Parameter | Description |
---|---|
custom Type: PubNub.RequestConfiguration Default: PubNub.RequestConfiguration() | An object that allows for per-request customization of PubNub Configuration or Network Session. |
completion Type: ((Result<Timetoken, Error>) -> Void)? Default: nil | The async Result of the method call. |
Completion handler result
Success
The current Timetoken
.
Failure
An Error
describing the failure.
Sample code
Get PubNub timetoken