API reference
In this section, you'll find the documentation for the classes and methods available in the Swift SDK.
Knock
The top-level Knock class. Create an authenticated Knock client instance for interacting with Knock.
Params
Example
publishableKey
Returns the publishable key set on the client.
Returns: string
userId
Returns the userId set.
Returns: string
userToken
Returns the userToken set.
Returns: string
getUser
Returns the current user's profile stored in Knock.
Returns
Result<User, Error>
updateUser
Updates the current user's profile in Knock.
Params
Returns
Result<User, Error>
getAllUserPreferences
Returns all of the preference sets for the current user.
Returns
Result<[PreferenceSet], Error>
getUserPreferences
Returns a single preference set for the current user, specified by the preferenceId
. For the default preference set, set the preferenceId
to be default
.
Params
Returns
Result<PreferenceSet, Error>
setUserPreferences
Updates the preference set specified by the preferenceId
with the new preferenceSet
.
Params
Returns
Result<PreferenceSet, Error>
getUserChannelData
Returns the channel data for the current user on the channel specified with channelId
.
Params
Returns
Result<ChannelData, Error>
updateUserChannelData
Updates the channel data for the current user on the channel specified with channelId
.
Params
Returns
Result<ChannelData, Error>
registerTokenForAPNS
A convenience method for getting and setting channel data for an APNS channel for the current user.
Params
Returns
Result<ChannelData, Error>
getMessage
Returns information about a single message specified by the messageId
.
Params
Returns
Result<KnockMessage, Error>
updateMessageStatus
Updates the status of a single message specified by the message
or messageId
.
Params
Returns
Result<KnockMessage, Error>
deleteMessageStatus
Removes the update of a single message status specified by the message
or messageId
.
Params
Returns
Result<KnockMessage, Error>
batchUpdateStatuses
Updates up to 50 messages with the given status in a single request specified by messageIds
or messages
.
Params
Returns
Result<[KnockMessage], Error>
Knock.FeedManager
Creates a new instance of a FeedManager
for interacting with a user's in-app notification feed.
Params
Example
connectToFeed
Connects the feed instance to the real-time socket so that any new items published to the feed are received over the websocket.
Params
Returns
Void
disconnectFromFeed
Disconnects a connected real-time instance.
Returns
Void
on
Binds an event listener for incoming web socket events. Must have called connectToFeed
first.
Returns
Void
Example
getUserFeedContent
Retrieves the user's feed content for the feed. Can be scoped by passing options
, which also allows for paginating the contents of the feed using the before
and after
cursors.
Params
Returns
Result<Feed, Error>
Example
makeBulkStatusUpdate
Updates all of the items within the feed with the given status. Can be passed options
to scope the request further. Note: this method returns a BulkUpdate
via the Knock API, which is an async operation.
Params
Returns
Result<BulkOperation, Error>
FeedManager.FeedClientOptions
Used to scope a feed request.
Params