SwiftSwift Native SDK Status Events

 
The PubNub Swift 3.0 SDK contains many significant changes from the 2.x SDK, including breaking changes. Please refer to the PubNub Swift 3.0 Migration Guide for more details.

The ConnectionStatus enum defines the following values:

CaseDescription
connectingThe connection is in the process of connecting
connectedThe connection has been established
reconnectingThe connection was dropped and is in the process of connecting
disconnectedThe connection no longer exists
disconnectedUnexpectedlyThe connection was unexpectedly disconnected

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

CaseDescription
isActiveThe connection is connecting, connected, or reconnecting
isConnectedThe connection is connected

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

 

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

A failure occurred during URL creation.

PubNubError.Reason CaseDescription
missingRequiredParameterA required parameter was missing or empty
invalidEndpointTypeThe endpoint is invalid for the action being performed
missingPublishKeyRequired PubNub publish key is missing
missingSubscribeKeyRequired PubNub subscribe key is missing
missingPublishAndSubscribeKeyRequired publish and subscribe keys are both missing

Encoding or decoding of a Codable object failed.

PubNubError.Reason CaseDescription
jsonStringEncodingFailureThe object couldn't be encoded into stringified JSON
jsonStringDecodingFailureThe stringified JSON couldn't be decoded into the requested object
jsonDataEncodingFailureThe object couldn't be encoded into JSON data
jsonDataDecodingFailureThe JSON data couldn't be decoded into the requested object

An error occurred while preparing or evaluating the Request.

PubNubError.Reason CaseDescription
requestMutatorFailureThe request mutation failed
requestRetryFailedThe request reached the maximum retry count

A failure occurred performing a Crypto operation.

PubNubError.Reason CaseDescription
missingCryptoKeyMissing cipher key from PubNubConfiguration

A failure occurred transmitting the request.

PubNubError.Reason CaseDescription
timedOutAn asynchronous operation timed out
nameResolutionFailureThe host name for a URL couldn't be resolved
invalidURLA malformed/unsupported URL prevented a URL request from being initiated
connectionFailureA network resource was requested, but an internet connection hasn’t been established and can’t be established automatically
connectionOverDataFailureThe request couldn't be completed due to issues with the cellular network
connectionLostA client or server connection was severed in the middle of a request
secureConnectionFailureAn attempt to establish a secure connection failed for reasons that can’t be expressed more specifically
certificateTrustFailureThere was an issue with the secure server certificate

The client platform failed when receiving the response.

PubNubError.Reason CaseDescription
badServerResponseThe URL Loading system received bad data from the server
responseDecodingFailureClient system couldn't parse network response
dataLengthExceedsMaximumThe length of the resource data exceeds the maximum allowed

A response was malformed in some way.

PubNubError.Reason CaseDescription
missingCriticalResponseDataRequest or response is nil without an underlying error
unrecognizedStatusCodeAn unrecognized response error code was received and couldn't be categorized
malformedResponseBodyResponse is valid JSON but not formatted as expected

The request was cancelled before completing.

PubNubError.Reason CaseDescription
clientCancelledThe request was cancelled by the application/user without error
sessionDeinitializedThis Session was deinitialized while tasks were still executing
sessionInvalidatedThis Session's underlying URLSession was invalidated
longPollingRestartThe long polling request needed to be cancelled to restart with new data

The PubNub endpoint responded with an error.

PubNubError.Reason CaseDescription
invalidArgumentsAt least one Request parameter is invalid
invalidCharacterAt least one invalid character in the Request
invalidDevicePushTokenThe provided device token isn't a valid push token
invalidSubscribeKeyThe PubNub subscribe key used for the request is invalid
invalidPublishKeyThe PubNub publish key used for the request is invalid
maxChannelGroupCountExceededThe maximum number of channel groups has been reached
couldNotParseRequestThe PubNub server was unable to parse the request
requestContainedInvalidJSONThe request contained a malformed JSON payload
serviceUnavailableThe server took longer to respond than the maximum allowed processing time
messageCountExceededMaximumThe number of messages returned exceeded the maximum allowed
badRequestAn unexpected error occurred while processing the request
conflictObject was changed by another request since last retrieval
preconditionFailedRequest payload must be in JSON format
tooManyRequestsYou have exceeded the maximum number of requests per second allowed for your subscriber key
unsupportedTypeYou sent an unsupported object to the server
unauthorizedAccess denied due to insufficient authentication/authorization
forbiddenAuthorization key is missing or doesn't have the permissions required to perform this operation
resourceNotFoundRequested resource not found at that endpoint
requestURITooLongURI of the request was too long to be processed
malformedFilterExpressionThe supplied filter expression was malformed
internalServiceErrorAn unexpected error occurred while processing the request
messageTooLongThe message you attempted to publish was too large to transmit successfully
invalidUUIDCouldn't complete action due to wrong UUID specified
nothingToDeleteThere was nothing to delete
failedToPublishThe operation successfully stored the value, but failed to publish

Failure due to one or more services not enabled.

PubNubError.Reason CaseDescription
pushNotEnabledUse of the mobile push notifications API requires the Push Notifications add-on, which isn't enabled for this subscribe key
messageDeletionNotEnabledUse of the history delete API requires the Storage & Playback and Storage Delete add-ons enabled, at least one of which isn't enabled for this subscribe key
messageHistoryNotEnabledUse of the history API requires the Storage & Playback add-on which isn't enabled for this subscribe key
multiplexingNotEnabledUse of Multiplexing requires Stream Controller to be enabled for this subscribe key

An unknown error has occurred.

PubNubError.Reason CaseDescription
unknownReason unknown