PostHog iOS SDK
SDK Version:
PostHogSDK
The PostHogSDK class
Initialization methods
Examples
Returns
| Type |
|---|
Void |
withpublic
with method
Parameters
| Name | Type |
|---|---|
param0 | PostHogConfig |
The param0 parameter | |
param1 | PostHogSDK |
The param1 parameter | |
Examples
Returns
| Type |
|---|
Void |
Capture methods
capturepublic
capture method
Parameters
| Name | Type |
|---|---|
event | String |
The event parameter | |
Examples
Returns
| Type |
|---|
Void |
capturepublic
capture method
Parameters
| Name | Type |
|---|---|
event | String |
The event parameter | |
distinctId | String |
The distinctId parameter | |
properties | String |
The properties parameter | |
userProperties | String |
The userProperties parameter | |
userPropertiesSetOnce | String |
The userPropertiesSetOnce parameter | |
groups | String |
The groups parameter | |
properties | String |
The properties parameter | |
Examples
Returns
| Type |
|---|
Void |
capturepublic
capture method
Parameters
| Name | Type |
|---|---|
event | String |
The event parameter | |
distinctId | String |
The distinctId parameter | |
properties | String |
The properties parameter | |
userProperties | String |
The userProperties parameter | |
userPropertiesSetOnce | String |
The userPropertiesSetOnce parameter | |
groups | String |
The groups parameter | |
properties | String |
The properties parameter | |
timestamp | Date |
The timestamp parameter | |
Examples
Returns
| Type |
|---|
Void |
capturepublic
capture method
Parameters
| Name | Type |
|---|---|
event | String |
The event parameter | |
properties | String |
The properties parameter | |
Examples
Returns
| Type |
|---|
Void |
capturepublic
capture method
Parameters
| Name | Type |
|---|---|
event | String |
The event parameter | |
properties | String |
The properties parameter | |
userProperties | String |
The userProperties parameter | |
Examples
Returns
| Type |
|---|
Void |
capturepublic
capture method
Parameters
| Name | Type |
|---|---|
event | String |
The event parameter | |
properties | String |
The properties parameter | |
userProperties | String |
The userProperties parameter | |
userPropertiesSetOnce | String |
The userPropertiesSetOnce parameter | |
Examples
Returns
| Type |
|---|
Void |
capturepublic
capture method
Parameters
| Name | Type |
|---|---|
event | String |
The event parameter | |
properties | String |
The properties parameter | |
userProperties | String |
The userProperties parameter | |
userPropertiesSetOnce | String |
The userPropertiesSetOnce parameter | |
groups | String |
The groups parameter | |
properties | String |
The properties parameter | |
Examples
Returns
| Type |
|---|
Void |
flushpublic
flush method
Examples
Returns
| Type |
|---|
Void |
registerpublic
register method
Examples
Returns
| Type |
|---|
Void |
screenpublic
screen method
Parameters
| Name | Type |
|---|---|
name | String |
The name parameter | |
Examples
Returns
| Type |
|---|
Void |
screenpublic
screen method
Parameters
| Name | Type |
|---|---|
name | String |
The name parameter | |
properties | String |
The properties parameter | |
Examples
Returns
| Type |
|---|
Void |
unregisterpublic
unregister method
Parameters
| Name | Type |
|---|---|
param0 | String |
The param0 parameter | |
Examples
Returns
| Type |
|---|
Void |
Configuration methods
closepublic
close method
Examples
Returns
| Type |
|---|
Void |
debugpublic
debug method
Parameters
| Name | Type |
|---|---|
param0 | Bool |
The param0 parameter | |
Examples
Returns
| Type |
|---|
Void |
grouppublic
group method
Parameters
| Name | Type |
|---|---|
type | String |
The type parameter | |
key | String |
The key parameter | |
Examples
Returns
| Type |
|---|
Void |
grouppublic
group method
Parameters
| Name | Type |
|---|---|
type | String |
The type parameter | |
key | String |
The key parameter | |
groupProperties | String |
The groupProperties parameter | |
Examples
Returns
| Type |
|---|
Void |
didStartNotificationpublic
didStartNotification method
Examples
Returns
| Type |
|---|
Void |
sharedpublic
shared method
Examples
Returns
| Type |
|---|
Void |
Feature flags methods
getFeatureFlagpublic
getFeatureFlag method
Parameters
| Name | Type |
|---|---|
param0 | String |
The param0 parameter | |
Examples
Returns
| Type |
|---|
Void |
getFeatureFlagPayloadpublic
getFeatureFlagPayload method
Parameters
| Name | Type |
|---|---|
param0 | String |
The param0 parameter | |
Examples
Returns
| Type |
|---|
Void |
isFeatureEnabledpublic
isFeatureEnabled method
Parameters
| Name | Type |
|---|---|
param0 | String |
The param0 parameter | |
param1 | Bool |
The param1 parameter | |
Examples
Returns
| Type |
|---|
Void |
reloadFeatureFlagspublic
reloadFeatureFlags method
Examples
Returns
| Type |
|---|
Void |
reloadFeatureFlagspublic
reloadFeatureFlags method
Examples
Returns
| Type |
|---|
Void |
resetGroupPropertiesForFlagspublic
Clears all group properties for feature flag evaluation.
Notes:
Clears all group properties for feature flag evaluation.
Examples
Returns
| Type |
|---|
Void |
resetGroupPropertiesForFlagspublic
Clears group properties for feature flag evaluation for a specific group type.
Notes:
Clears group properties for feature flag evaluation for a specific group type.
Parameters
| Name | Type |
|---|---|
groupType | Any |
The group type to clear properties for | |
Examples
Returns
| Type |
|---|
Void |
resetPersonPropertiesForFlagspublic
Resets all person properties that were set for feature flag evaluation.
Notes:
After calling this method, feature flag evaluation will only use server-side person properties and will not include any locally overridden properties.
Examples
Returns
| Type |
|---|
Void |
setGroupPropertiesForFlagspublic
Sets properties for a specific group type to include when evaluating feature flags. These properties supplement the standard group information sent to PostHog for flag evaluation, providing additional context that can be used in flag targeting conditions.
Notes:
Sets properties for a specific group type to include when evaluating feature flags. These properties supplement the standard group information sent to PostHog for flag evaluation, providing additional context that can be used in flag targeting conditions.
Parameters
| Name | Type |
|---|---|
groupType | Any |
The group type identifier (e.g., “organization”, “team”) | |
properties | String |
Dictionary of properties to set for this group type | |
Examples
Returns
| Type |
|---|
Void |
setGroupPropertiesForFlagspublic
Sets properties for a specific group type to include when evaluating feature flags. These properties supplement the standard group information sent to PostHog for flag evaluation, providing additional context that can be used in flag targeting conditions.
Notes:
Sets properties for a specific group type to include when evaluating feature flags. These properties supplement the standard group information sent to PostHog for flag evaluation, providing additional context that can be used in flag targeting conditions.
Parameters
| Name | Type |
|---|---|
groupType | Any |
The group type identifier (e.g., “organization”, “team”) | |
properties | String |
Dictionary of properties to set for this group type | |
reloadFeatureFlags | Bool |
Whether to automatically reload feature flags after setting properties | |
Examples
Returns
| Type |
|---|
Void |
setPersonPropertiesForFlagspublic
Sets person properties that will be included in feature flag evaluation requests.
Notes:
This method allows you to override server-side person properties for immediate feature flag evaluation, solving the race condition where person properties from calls may not have been processed by the server yet. Properties are merged additively with existing properties. Feature flags are automatically reloaded after setting properties.
Parameters
| Name | Type |
|---|---|
properties | Any |
Dictionary of person properties to include in flag evaluation | |
Examples
Returns
| Type |
|---|
Void |
setPersonPropertiesForFlagspublic
Sets person properties that will be included in feature flag evaluation requests.
Notes:
This method allows you to override server-side person properties for immediate feature flag evaluation, solving the race condition where person properties from calls may not have been processed by the server yet. Properties are merged additively with existing properties.
Parameters
| Name | Type |
|---|---|
properties | Any |
Dictionary of person properties to include in flag evaluation | |
reloadFeatureFlags | Bool |
Whether to automatically reload feature flags after setting properties | |
Examples
Returns
| Type |
|---|
Void |
didReceiveFeatureFlagspublic
didReceiveFeatureFlags method
Examples
Returns
| Type |
|---|
Void |
Identification methods
aliaspublic
alias method
Parameters
| Name | Type |
|---|---|
alias | String |
The alias parameter | |
Examples
Returns
| Type |
|---|
Void |
getAnonymousIdpublic
getAnonymousId method
Examples
Returns
| Type |
|---|
Void |
getDistinctIdpublic
getDistinctId method
Examples
Returns
| Type |
|---|
Void |
identifypublic
identify method
Parameters
| Name | Type |
|---|---|
distinctId | String |
The distinctId parameter | |
Examples
Returns
| Type |
|---|
Void |
identifypublic
identify method
Parameters
| Name | Type |
|---|---|
distinctId | String |
The distinctId parameter | |
userProperties | String |
The userProperties parameter | |
Examples
Returns
| Type |
|---|
Void |
identifypublic
identify method
Parameters
| Name | Type |
|---|---|
distinctId | String |
The distinctId parameter | |
userProperties | String |
The userProperties parameter | |
userPropertiesSetOnce | String |
The userPropertiesSetOnce parameter | |
Examples
Returns
| Type |
|---|
Void |
Privacy methods
isOptOutpublic
isOptOut method
Examples
Returns
| Type |
|---|
Void |
optInpublic
optIn method
Examples
Returns
| Type |
|---|
Void |
optOutpublic
optOut method
Examples
Returns
| Type |
|---|
Void |
resetpublic
reset method
Examples
Returns
| Type |
|---|
Void |
Session replay methods
endSessionpublic
endSession method
Examples
Returns
| Type |
|---|
Void |
getSessionIdpublic
getSessionId method
Examples
Returns
| Type |
|---|
Void |
startSessionpublic
startSession method
Examples
Returns
| Type |
|---|
Void |
PostHogDisplaySurvey
A model representing a PostHog survey to be displayed to users
Configuration methods
appearancepublic
Optional appearance configuration for customizing the survey’s look and feel
Notes:
Optional appearance configuration for customizing the survey’s look and feel
Examples
Returns
| Type |
|---|
Void |
endDatepublic
Optional date indicating when the survey should stop being shown
Notes:
Optional date indicating when the survey should stop being shown
Examples
Returns
| Type |
|---|
Void |
idpublic
Unique identifier for the survey
Notes:
Unique identifier for the survey
Examples
Returns
| Type |
|---|
Void |
namepublic
Name of the survey
Notes:
Name of the survey
Examples
Returns
| Type |
|---|
Void |
questionspublic
Array of questions to be presented in the survey
Notes:
Array of questions to be presented in the survey
Examples
Returns
| Type |
|---|
Void |
startDatepublic
Optional date indicating when the survey should start being shown
Notes:
Optional date indicating when the survey should start being shown
Examples
Returns
| Type |
|---|
Void |
PostHogDisplayLinkQuestion
Represents a question with a clickable link
Configuration methods
linkpublic
The URL that will be opened when the link is clicked
Notes:
The URL that will be opened when the link is clicked
Examples
Returns
| Type |
|---|
Void |
PostHogDisplayChoiceQuestion
Represents a multiple or single choice question where users can select one or more options
Configuration methods
choicespublic
The list of options for the user to choose from
Notes:
The list of options for the user to choose from
Examples
Returns
| Type |
|---|
Void |
hasOpenChoicepublic
Whether the question includes an “other” option for users to input free-form text
Notes:
Whether the question includes an “other” option for users to input free-form text
Examples
Returns
| Type |
|---|
Void |
isMultipleChoicepublic
Whether the user can select multiple options
Notes:
Whether the user can select multiple options
Examples
Returns
| Type |
|---|
Void |
shuffleOptionspublic
Whether the options should be shuffled to randomize the order
Notes:
Whether the options should be shuffled to randomize the order
Examples
Returns
| Type |
|---|
Void |
PostHogNextSurveyQuestion
A model representing the next state of the survey progression.
Configuration methods
isSurveyCompletedpublic
Whether all questions have been answered and the survey is complete Depending on the survey appearance configuration, you may want to show the “Thank you” message or dismiss the survey at this point
Notes:
Whether all questions have been answered and the survey is complete Depending on the survey appearance configuration, you may want to show the “Thank you” message or dismiss the survey at this point
Examples
Returns
| Type |
|---|
Void |
questionIndexpublic
The index of the next question to be displayed (0-based)
Notes:
The index of the next question to be displayed (0-based)
Examples
Returns
| Type |
|---|
Void |
PostHogStorageManager
The PostHogStorageManager class
Configuration methods
isIdentifiedpublic
isIdentified method
Examples
Returns
| Type |
|---|
Void |
isPersonProcessingpublic
isPersonProcessing method
Examples
Returns
| Type |
|---|
Void |
setAnonymousIdpublic
setAnonymousId method
Parameters
| Name | Type |
|---|---|
param0 | String |
The param0 parameter | |
Examples
Returns
| Type |
|---|
Void |
setDistinctIdpublic
setDistinctId method
Parameters
| Name | Type |
|---|---|
param0 | String |
The param0 parameter | |
Examples
Returns
| Type |
|---|
Void |
setIdentifiedpublic
setIdentified method
Parameters
| Name | Type |
|---|---|
param0 | Bool |
The param0 parameter | |
Examples
Returns
| Type |
|---|
Void |
setPersonProcessingpublic
setPersonProcessing method
Parameters
| Name | Type |
|---|---|
param0 | Bool |
The param0 parameter | |
Examples
Returns
| Type |
|---|
Void |
Identification methods
getAnonymousIdpublic
getAnonymousId method
Examples
Returns
| Type |
|---|
Void |
getDistinctIdpublic
getDistinctId method
Examples
Returns
| Type |
|---|
Void |
Privacy methods
resetpublic
reset method
Parameters
| Name | Type |
|---|---|
keepAnonymousId | Bool |
The keepAnonymousId parameter | |
param1 | Bool |
The param1 parameter | |
Examples
Returns
| Type |
|---|
Void |
PostHogDisplayOpenQuestion
Represents an open-ended question where users can input free-form text
PostHogEvent
The PostHogEvent class
Configuration methods
distinctIdpublic
distinctId method
Examples
Returns
| Type |
|---|
Void |
eventpublic
event method
Examples
Returns
| Type |
|---|
Void |
propertiespublic
properties method
Examples
Returns
| Type |
|---|
Void |
timestamppublic
timestamp method
Examples
Returns
| Type |
|---|
Void |
uuidpublic
uuid method
Examples
Returns
| Type |
|---|
Void |
PostHogSurveyResponse
A model representing a user’s response to a survey question
Configuration methods
linkClickedpublic
Whether a link was clicked (for link questions)
Notes:
Whether a link was clicked (for link questions)
Examples
Returns
| Type |
|---|
Void |
ratingValuepublic
The numeric rating value (for rating questions)
Notes:
The numeric rating value (for rating questions)
Examples
Returns
| Type |
|---|
Void |
selectedOptionspublic
The selected options (for multiple or single choice questions)
Notes:
The selected options (for multiple or single choice questions)
Examples
Returns
| Type |
|---|
Void |
textValuepublic
The text response (for open questions)
Notes:
The text response (for open questions)
Examples
Returns
| Type |
|---|
Void |
typepublic
The type of response (link, rating, text, or multiple choice)
Notes:
The type of response (link, rating, text, or multiple choice)
Examples
Returns
| Type |
|---|
Void |
linkpublic
Creates a response for a link question
Notes:
Creates a response for a link question
Parameters
| Name | Type |
|---|---|
clicked | Any |
Whether the link was clicked | |
Examples
Returns
| Type |
|---|
Void |
multipleChoicepublic
Creates a response for a multiple-choice question
Notes:
Creates a response for a multiple-choice question
Parameters
| Name | Type |
|---|---|
multipleChoice | Any |
The selected options | |
Examples
Returns
| Type |
|---|
Void |
openEndedpublic
Creates a response for an open-ended question
Notes:
Creates a response for an open-ended question
Parameters
| Name | Type |
|---|---|
openEnded | Any |
The text response | |
Examples
Returns
| Type |
|---|
Void |
ratingpublic
Creates a response for a rating question
Notes:
Creates a response for a rating question
Parameters
| Name | Type |
|---|---|
rating | Any |
The selected rating value | |
Examples
Returns
| Type |
|---|
Void |
singleChoicepublic
Creates a response for a single-choice question
Notes:
Creates a response for a single-choice question
Parameters
| Name | Type |
|---|---|
singleChoice | Any |
The selected option | |
Examples
Returns
| Type |
|---|
Void |
PostHogDisplaySurveyQuestion
Base class for all survey question types
Configuration methods
buttonTextpublic
Optional custom text for the question’s action button
Notes:
Optional custom text for the question’s action button
Examples
Returns
| Type |
|---|
Void |
idpublic
The question ID, empty if none
Notes:
The question ID, empty if none
Examples
Returns
| Type |
|---|
Void |
isOptionalpublic
Whether the question can be skipped
Notes:
Whether the question can be skipped
Examples
Returns
| Type |
|---|
Void |
questionpublic
The main question text to display
Notes:
The main question text to display
Examples
Returns
| Type |
|---|
Void |
questionDescriptionpublic
Optional additional description or context for the question
Notes:
Optional additional description or context for the question
Examples
Returns
| Type |
|---|
Void |
questionDescriptionContentTypepublic
Content type for the question description (HTML or plain text)
Notes:
Content type for the question description (HTML or plain text)
Examples
Returns
| Type |
|---|
Void |
PostHogSessionManager
The PostHogSessionManager class
Configuration methods
sharedpublic
shared method
Examples
Returns
| Type |
|---|
Void |
Session replay methods
setSessionIdpublic
setSessionId method
Parameters
| Name | Type |
|---|---|
param0 | String |
The param0 parameter | |
Examples
Returns
| Type |
|---|
Void |
PostHogSurveysConfig
The PostHogSurveysConfig class
Configuration methods
surveysDelegatepublic
Delegate responsible for managing survey presentation in your app. Handles survey rendering, response collection, and lifecycle events. You can provide your own delegate for a custom survey presentation.
Notes:
Defaults to which provides a standard survey UI.
Examples
Returns
| Type |
|---|
Void |
PostHogDisplayRatingQuestion
Represents a rating question where users can select a rating from a scale
Configuration methods
lowerBoundLabelpublic
The label for the lower bound of the rating scale
Notes:
The label for the lower bound of the rating scale
Examples
Returns
| Type |
|---|
Void |
ratingTypepublic
The type of rating scale (numbers, emoji)
Notes:
The type of rating scale (numbers, emoji)
Examples
Returns
| Type |
|---|
Void |
scaleLowerBoundpublic
The lower bound of the rating scale
Notes:
The lower bound of the rating scale
Examples
Returns
| Type |
|---|
Void |
scaleUpperBoundpublic
The upper bound of the rating scale
Notes:
The upper bound of the rating scale
Examples
Returns
| Type |
|---|
Void |
upperBoundLabelpublic
The label for the upper bound of the rating scale
Notes:
The label for the upper bound of the rating scale
Examples
Returns
| Type |
|---|
Void |
PostHogDisplaySurveyAppearance
Model that describes the appearance customization of a PostHog survey
Configuration methods
backgroundColorpublic
Optional background color as web color (e.g. “#FFFFFF” or “white”)
Notes:
Optional background color as web color (e.g. “#FFFFFF” or “white”)
Examples
Returns
| Type |
|---|
Void |
borderColorpublic
Optional border color as web color
Notes:
Optional border color as web color
Examples
Returns
| Type |
|---|
Void |
descriptionTextColorpublic
Optional color for description text as web color
Notes:
Optional color for description text as web color
Examples
Returns
| Type |
|---|
Void |
displayThankYouMessagepublic
Whether to show a thank you message after survey completion
Notes:
Whether to show a thank you message after survey completion
Examples
Returns
| Type |
|---|
Void |
fontFamilypublic
Optional font family to use throughout the survey
Notes:
Optional font family to use throughout the survey
Examples
Returns
| Type |
|---|
Void |
placeholderpublic
Optional placeholder text for input fields
Notes:
Optional placeholder text for input fields
Examples
Returns
| Type |
|---|
Void |
ratingButtonActiveColorpublic
Optional color for active/selected rating buttons as web color
Notes:
Optional color for active/selected rating buttons as web color
Examples
Returns
| Type |
|---|
Void |
ratingButtonColorpublic
Optional color for rating buttons as web color
Notes:
Optional color for rating buttons as web color
Examples
Returns
| Type |
|---|
Void |
submitButtonColorpublic
Optional background color for the submit button as web color
Notes:
Optional background color for the submit button as web color
Examples
Returns
| Type |
|---|
Void |
submitButtonTextpublic
Optional custom text for the submit button
Notes:
Optional custom text for the submit button
Examples
Returns
| Type |
|---|
Void |
submitButtonTextColorpublic
Optional text color for the submit button as web color
Notes:
Optional text color for the submit button as web color
Examples
Returns
| Type |
|---|
Void |
thankYouMessageCloseButtonTextpublic
Optional text for the close button in the thank you message
Notes:
Optional text for the close button in the thank you message
Examples
Returns
| Type |
|---|
Void |
thankYouMessageDescriptionpublic
Optional description text for the thank you message
Notes:
Optional description text for the thank you message
Examples
Returns
| Type |
|---|
Void |
thankYouMessageDescriptionContentTypepublic
Optional content type for the thank you message description
Notes:
Optional content type for the thank you message description
Examples
Returns
| Type |
|---|
Void |
thankYouMessageHeaderpublic
Optional header text for the thank you message
Notes:
Optional header text for the thank you message
Examples
Returns
| Type |
|---|
Void |