Flutter API reference
The complete API reference for the Knock Flutter SDK.
In this section, you'll find the documentation for the classes and methods available in the Flutter SDK.
Knock
#The top-level Knock class. Create an authenticated Knock client instance for interacting with Knock.
Params
The public API key for the Knock environment.
Any additional options to instantiate your Knock instance with.
Returns
Knock
authenticate
#Authenticates the current user.
Params
The ID of the user to authenticate against.
The signed user token, required when using enhanced security mode in the environment.
Returns
void
logout
#Clears any user authentication and disposes of any created clients.
Returns
void
isAuthenticated
#Returns whether or this Knock instance is authenticated. Passing true
will check the presence of the userToken
as well.
Returns
bool
dispose
#Releases any connected resources used by this instance.
Returns
void
getApnsToken
#Returns the current device's APNs token. Only relevant for iOS applications.
Returns
Future<String>
getFcmToken
#Returns the current device's FCM token.
Returns
Future<String>
user
#Returns the current user client.
Returns
UserClient
preferences
#Returns the current preferences client.
Returns
PreferencesClient
feed
#Returns a new feed client for the channel ID specified.
Params
The channel ID from Knock for the in-app feed.
Any additional options to instantiate your feed instance with.
Returns
FeedClient
UserClient
#Methods for interacting with the current user resource in Knock. You access this under knock.user()
.
get
#Returns the current authenticated user from Knock.
Returns
Future<User>
identify
#Upserts the current authenticated user properties in Knock.
Returns
Future<User>
getChannelData
#Returns any channel data set for the channelId given for the current authenticated user.
The channel ID from Knock.
Returns
Future<ChannelData>
setChannelData
#Updates the channel data for the current user on the channel specified with channelId
.
Params
The channel ID to update the channel data for.
The data to update for the channel data.
Returns
Future<ChannelData>
registerTokenForChannel
#Registers the current device's token for the user in Knock.
Params
The push channel ID from Knock.
The device token to register.
Returns
Future<ChannelData>
deregisterTokenForChannel
#De-registers the current device's token for the user in Knock.
Params
The push channel ID from Knock.
The device token to remove.
Returns
Future<ChannelData>
PreferencesClient
#getAll
#Returns all preference sets for the current user.
Returns
Future<List<PreferenceSet>>
get
#Returns a single preference set for the current user.
Returns
Future<PreferenceSet>
set
#The preference set to upsert.
Returns
Future<PreferenceSet>
FeedClient
#The in-app channel ID from Knock.
Default options to apply to the feed instance.
Returns
FeedClient
feed
#Returns the current feed controller to be bound and used when building UI.
Returns
Stream<Feed>
fetchNextPage
#Fetches the next page of items in the feed, as long as there are more items to fetch.
Returns
void
on
#Binds an event listener to the feed.
Params
The type of event to listen to.
Returns
Stream<FeedEvent>
markAsSeen
#Marks the given set of items as seen. Will optimistically update the feed.
Params
One or more feed items to mark.
Returns
Future<void>
markAsUnseen
#Marks the given set of items as unseen. Will optimistically update the feed.
Params
One or more feed items to mark.
Returns
Future<void>
markAsRead
#Marks the given set of items as read. Will optimistically update the feed.
Params
One or more feed items to mark.
Returns
Future<void>
markAsUnread
#Marks the given set of items as unread. Will optimistically update the feed.
Params
One or more feed items to mark.
Returns
Future<void>
markAsArchived
#Marks the given set of items as archived. Will optimistically update the feed.
Params
One or more feed items to mark.
Returns
Future<void>
markAsUnarchived
#Marks the given set of items as unarchived. Will optimistically update the feed.
Params
One or more feed items to mark.
Returns
Future<void>
markAsInteracted
#Marks the given set of items as interacted. Will optimistically update the feed.
Params
One or more feed items to mark.
Returns
Future<void>
markAllAsSeen
#Marks all items in the user's feed as seen. Will optimistically update the items currently in the feed.
Returns
Future<void>
markAllAsRead
#Marks all items in the user's feed as read. Will optimistically update the items currently in the feed.
Returns
Future<void>
markAllAsArchived
#Marks all items in the user's feed as archived. Will optimistically update the items currently in the feed.
Returns
Future<void>