Additional Methods#
Table of Contents#
Static Attributes#
delegate#
The delegate is responsible for things like fetching ads, handling deeplinks. More detailed info can be found here.
modules#
This is a list of StorytellerModule instances that deal mainly with fetching ads and handling user activity for analytics, alongside the delegate.
currentApiKey#
This is the current API key set when using initialize.
currentUserId#
Deprecated. Always returns an empty string. Will be removed in a future release.
version#
This is a static strong property that holds the current SDK version.
isInitialized#
This is a boolean static property which is set to true if Storyteller was successfully initialized.
isPresentingContent#
A Boolean value indicating whether Storyteller content is currently presented.
This property is true when a Story Player, Clip Player, Search or Sheet is visible, and false otherwise. It updates automatically when content is presented or dismissed.
isSearchEnabled#
This is a boolean static property which is set to true if the Search feature is enabled in the Storyteller configuration.
isSearchEnabled#
This is a boolean static property which is set to true if the Search feature is enabled in the Storyteller configuration.
theme#
This is the default fallback theming style used to render Story or Clips items in lists and activities launched from lists.
user#
Allows setting or removing custom attributes for audience targeting. Please see User Customization
Storyteller.shared.user.setCustomAttribute(key: "location", value: "New York")
eventTrackingOptions#
The eventTrackingOptions property customizes Storyteller's analytics and tracking behavior. This property is read-only and can only be set during SDK initialization. More about it here.
Static Methods#
Note, most of the below methods are async functions which need to either be called in a synchronized context, or via a Task.
initialize#
initialize(apiKey: String, userInput: StorytellerUserInput? = nil, eventTrackingOptions: StorytellerEventTrackingOptions = .enableAll) async throws
The initialize method is required to be called for Storyteller to work. It's recommended to fire this method as soon as possible in the app lifecycle.
Parameters:
- apiKey - This is the API key provided by the Storyteller team.
- userInput - This is the ID of the user to be authorized. See Working with Users for more information on user IDs.
- eventTrackingOptions - Configures analytics and tracking behavior. Defaults to
.enableAllwhich enables all tracking options. Once set during initialization, these options can only be changed by reinitializing the SDK. See Privacy and Tracking for more information.
Throws - if there is an issue with initialization.
dismissPlayer#
func dismissPlayer(animated: Bool, dismissReason: String? = nil) async
The dismissPlayer() force closes the currently open Story or Clips Player. If no Story or Clips Player is open when this is called, it has no effect.
Parameters:
animated- this decides whether to animate the dismissing of the view or notdismissReason- the reason why the Story/Page/Clip was force closed. This will be used to populate thedismissedReasonparameter of the correspondingonUserActivityOccurredcallback. If this is set tonulltheonUserActivityOccurredcallback will not be triggered.
openSearch#
func openSearch()
This method opens the Search screen.
resumePlayer#
func resumePlayer() async
This method resumes the currently open Story or Player Views. If no Player is open when this is called, it has no effect.
openSheet#
func openSheet(id: String)
This method loads and opens a Sheet with the corresponding ID.
getStoriesCount#
func getStoriesCount(for categories: [String]) async -> Int
This method retrieves the total count of Stories for the specified category IDs.
getClipsCount#
func getClipsCount(for collectionId: String) async -> Int
This method retrieves the total count of Clips in the specified Collection.