Configuration
SDK 3.x releases are not published to CocoaPods. Use Swift Package Manager or Carthage for current releases. Existing CocoaPods integrations can remain pinned to the version they already use, but will not receive SDK 3.x updates.
Initialization
Initialize the SDK once, typically in AppDelegate or SceneDelegate:
StorifyMeSDK.initialize(
accountId: "YOUR_ACCOUNT_ID",
apiKey: "YOUR_API_KEY",
environment: .EU
)
Customer ID
Set the customer identifier globally so it is used across widgets and direct experience requests:
StorifyMeInstance.shared.configureCustomerId("CUSTOMER_123")
The method also accepts an Int. StorifyMeWidgetConfig.setCustomerId(customerId:) is deprecated; use the global configuration method instead.
Custom Gateway Request Headers
If your custom gateway requires an app-owned session header, register the request interceptor before
initializing the SDK. It runs synchronously for each stories, base-template, audience, and ads content
API request routed through customBaseUrl, so the app can provide a refreshed token on every request.
The callback receives the absolute request URL and current headers, including accountId; return the
complete header map to send.
StorifyMeSDK.requestInterceptor = { url, headers in
var requestHeaders = headers
requestHeaders["Authorization"] = "Bearer \(session.currentToken())"
return requestHeaders
}
StorifyMeSDK.initialize(
accountId: "YOUR_ACCOUNT_ID",
apiKey: "YOUR_API_KEY",
environment: .EU,
customBaseUrl: "https://gateway.example.com"
)
The interceptor only applies to content API requests using the configured custom base URL. It does not add headers to media or WebView traffic. The SDK does not store or log returned header values. If the callback throws, the request fails. Keep it synchronous and make sure the gateway does not redirect requests to a different origin; the SDK does not reapply headers after redirects.
Set StorifyMeSDK.requestInterceptor = nil to unregister the callback.
Adding a Widget
let widget = StorifyMeWidget()
widget.setWidgetId(widgetId: YOUR_WIDGET_ID)
widget.load()
view.addSubview(widget)
widget.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
widget.leadingAnchor.constraint(equalTo: view.leadingAnchor),
widget.trailingAnchor.constraint(equalTo: view.trailingAnchor),
widget.heightAnchor.constraint(equalToConstant: 120)
])
Widgets automatically wait for SDK initialization, so load() can be called at any point.
Widget Configuration
Playback Behavior
storifyMeWidget.setPlaybackOptions(
options: StorifyMeExperiencePlaybackOptions(behaviour: .restartExperiencesOnAppLaunch)
)
| Option | Behavior |
|---|---|
alwaysResumeExperienceWhereStopped | Resume where the user stopped (default) |
restartExperiencesOnAppLaunch | Restart on every app launch |
restartExperiencesWhenOpen | Restart every time the widget is opened |
Audio Control
storifyMeWidget.setWidgetAudioOptions(
options: StorifyMeExperienceAudioOptions(
behaviour: .applyLastUserChangeForAllFutureExperiences,
defaultState: .unmuted
)
)
| Option | Behavior |
|---|---|
applyLastUserChangeForAllFutureExperiences | Remembers user's last audio choice (default) |
applyChangeForSingleExperience | Audio state resets for each experience |
applyChangeForPresentedExperiences | Audio state resets after the widget is dismissed |
Poster Thumbnails
storifyMeWidget.setGifPosterEnabled(true) // GIF posters — enabled by default
storifyMeWidget.setVideoPosterEnabled(true) // Video posters — disabled by default
URL Presentation
storifyMeWidget.setURLPresentationOptions(
options: StorifyMeURLPresentationOptions(presentationMode: .inAppBrowser)
)
.externalBrowser— open in Safari (default).inAppBrowser— open in-app
Direction and Language
var config = StorifyMeWidgetConfig()
config.setDirection(direction: .rtl)
config.setLanguage(languageCode: "en")
storifyMeWidget.setWidgetConfig(config: config)
Widgets use the device language and system appearance by default. Override the appearance for an individual widget when needed:
var config = StorifyMeWidgetConfig()
config.setTheme(theme: .dark)
config.setLanguage(languageCode: "en") // Omit to use the device language
storifyMeWidget.setWidgetConfig(config: config)
Filter by Experience IDs
Use setExperienceIds(experienceIds:) to limit a widget to a selected set of experiences:
var config = StorifyMeWidgetConfig()
config.setExperienceIds(experienceIds: [123, 456])
storifyMeWidget.setWidgetConfig(config: config)
Content Integrity Verification
For accounts with content signing enabled, pass your PEM-encoded ECDSA P-256 public keys during initialization. The array can contain multiple keys during key rotation.
let publicKeys = ["YOUR_PEM_ENCODED_ECDSA_P256_PUBLIC_KEY"]
StorifyMeSDK.initialize(
accountId: "YOUR_ACCOUNT_ID",
apiKey: "YOUR_API_KEY",
environment: .EU,
integrityPublicKeys: publicKeys
)
When keys are configured, each returned experience must carry a valid signature or the SDK drops it before rendering. Without keys, verification is disabled. Observe rejected content through StorifyMeWidgetDelegate.onIntegrityFailed(storyID:reason:).
Scroll Navigation
storifyMeWidget.setWidgetScrollNavigationOptions(
options: StorifyMeWidgetScrollNavigationOptions(storiesNavigation: .verticalCenteredControls)
)
Disable Onboarding
StorifyMeInstance.shared.disableInitialOnboarding()
Opening Experiences Programmatically
Open a specific experience from code — by position, handle, or ID:
storifyMeWidget.openWidgetExperienceByPosition(0, experienceBehaviour: nil) { result in }
storifyMeWidget.openWidgetExperienceByHandle("my-story-handle", experienceBehaviour: nil) { result in }
storifyMeWidget.openWidgetExperienceById(42, experienceBehaviour: nil) { result in }
To open an experience without a widget (for example, from a deep link or push notification):
StorifyMeSDK.openExperienceByHandle(handle: "my-story-handle")
Experience IDs, handles, and counts are available in the onLoaded event callback.
Utility Methods
Playback Control
StorifyMeInstance.shared.playbackController.pausePlayback(controlsVisibility: .visible)
StorifyMeInstance.shared.playbackController.resumePlayback(mode: .fromBeginning)
StorifyMeInstance.shared.playbackController.closePlayback()
Clear Seen State
storifyMeWidget.clearAllSeenState() // Clear all, refresh list
storifyMeWidget.clearSeenState(experienceID: 42) // Clear one experience
In-Story Notifications
StorifyMeInstance.shared.showNotification(title: "Title", message: "Message")