Status Events for Swift SDK

Connection Status Events

The ConnectionStatus enum defines the following values:

CaseDescription
connecting
The connection is in the process of connecting
connected
The connection has been established
reconnecting
The connection was dropped and is in the process of connecting
disconnected
The connection no longer exists
disconnectedUnexpectedly
The connection was unexpectedly disconnected

The ConnectionStatus enum also has the following properties, which you can use to verify details about the event:

CaseDescription
isActive
The connection is connecting, connected, or reconnecting
isConnected
The connection is connected

PubNub Error Events

If errors occur, PubNubError will be equatable to a PubNubError.Reasons case in one of the following categories:

Error objects

Most Error objects returned from the PubNub SDK can be cast to PubNubError using error.pubNubError.

URL Creation

A failure occurred during URL creation.

PubNubError.Reason CaseDescription
missingRequiredParameter
A required parameter was missing or empty
invalidEndpointType
The endpoint is invalid for the action being performed
missingPublishKey
Required PubNub publish key is missing
missingSubscribeKey
Required PubNub subscribe key is missing
missingPublishAndSubscribeKey
Required publish and subscribe keys are both missing

Codability

Encoding or decoding of a Codable object failed.

PubNubError.Reason CaseDescription
jsonStringEncodingFailure
The object couldn't be encoded into stringified JSON
jsonStringDecodingFailure
The stringified JSON couldn't be decoded into the requested object
jsonDataEncodingFailure
The object couldn't be encoded into JSON data
jsonDataDecodingFailure
The JSON data couldn't be decoded into the requested object

Request processing

An error occurred while preparing or evaluating the Request.

PubNubError.Reason CaseDescription
requestMutatorFailure
The request mutation failed
requestRetryFailed
The request reached the maximum retry count

Crypto

A failure occurred performing a Crypto operation.

PubNubError.Reason CaseDescription
missingCryptoKey
Missing cipher key from PubNubConfiguration

Request transmission

A failure occurred transmitting the request.

PubNubError.Reason CaseDescription
timedOut
An asynchronous operation timed out
nameResolutionFailure
The host name for a URL couldn't be resolved
invalidURL
A malformed/unsupported URL prevented a URL request from being initiated
connectionFailure
A network resource was requested, but an internet connection hasn't been established and can't be established automatically
connectionOverDataFailure
The request couldn't be completed due to issues with the cellular network
connectionLost
A client or server connection was severed in the middle of a request
secureConnectionFailure
An attempt to establish a secure connection failed for reasons that can't be expressed more specifically
certificateTrustFailure
There was an issue with the secure server certificate

Response receipt

The client platform failed when receiving the response.

PubNubError.Reason CaseDescription
badServerResponse
The URL Loading system received bad data from the server
responseDecodingFailure
Client system couldn't parse network response
dataLengthExceedsMaximum
The length of the resource data exceeds the maximum allowed

Response processing

A response was malformed in some way.

PubNubError.Reason CaseDescription
missingCriticalResponseData
Request or response is nil without an underlying error
unrecognizedStatusCode
An unrecognized response error code was received and couldn't be categorized
malformedResponseBody
Response is valid JSON but not formatted as expected

Cancellation

The request was cancelled before completing.

PubNubError.Reason CaseDescription
clientCancelled
The request was cancelled by the application/user without error
sessionDeinitialized
This Session was deinitialized while tasks were still executing
sessionInvalidated
This Session's underlying URLSession was invalidated
longPollingRestart
The long polling request needed to be cancelled to restart with new data

Endpoint response

The PubNub endpoint responded with an error.

PubNubError.Reason CaseDescription
invalidArguments
At least one Request parameter is invalid
invalidCharacter
At least one invalid character in the Request
invalidDevicePushToken
The provided device token isn't a valid push token
invalidSubscribeKey
The PubNub subscribe key used for the request is invalid
invalidPublishKey
The PubNub publish key used for the request is invalid
maxChannelGroupCountExceeded
The maximum number of channel groups has been reached
couldNotParseRequest
The PubNub server was unable to parse the request
requestContainedInvalidJSON
The request contained a malformed JSON payload
serviceUnavailable
The server took longer to respond than the maximum allowed processing time
messageCountExceededMaximum
The number of messages returned exceeded the maximum allowed
badRequest
An unexpected error occurred while processing the request
conflict
Object was changed by another request since last retrieval
preconditionFailed
Request payload must be in JSON format
tooManyRequests
You have exceeded the maximum number of requests per second allowed for your subscriber key
unsupportedType
You sent an unsupported object to the server
unauthorized
Access denied due to insufficient authentication/authorization
forbidden
Authorization key is missing or doesn't have the permissions required to perform this operation
resourceNotFound
Requested resource not found at that endpoint
requestURITooLong
URI of the request was too long to be processed
malformedFilterExpression
The supplied filter expression was malformed
internalServiceError
An unexpected error occurred while processing the request
messageTooLong
The message you attempted to publish was too large to transmit successfully
invalidUUID
Couldn't complete action due to wrong UUID specified
nothingToDelete
There was nothing to delete
failedToPublish
The operation successfully stored the value, but failed to publish

Service not enabled

Failure due to one or more services not enabled.

PubNubError.Reason CaseDescription
pushNotEnabled
Use of the mobile push notifications API requires the Mobile Push Notifications add-on, which isn't enabled for this subscribe key
messageDeletionNotEnabled
Use of the history delete API requires the Message Persistence and Storage Delete add-ons enabled, at least one of which isn't enabled for this subscribe key
messageHistoryNotEnabled
Use of the history API requires the Message Persistence add-on which isn't enabled for this subscribe key
multiplexingNotEnabled
Use of Multiplexing requires Stream Controller to be enabled for this subscribe key

Uncategorized

An unknown error has occurred.

PubNubError.Reason CaseDescription
unknown
Reason unknown
Last updated on