Survicate iOS SDK
The iOS SDK is distributed in a binary version and developed using Swift 5.7. For apps downloaded from the App Store, the Survicate iOS SDK adds ~ 7.2MB to your uncompressed app size on device. Note that the SDK features a Time To Live (TTL) mechanism of 60 seconds. This means any modifications made to your survey will be reflected on your respondents' devices after a delay of up to 60 seconds.
Requirements:
- Using Survicate Mobile SDK requires an account at survicate.com. You can create your account here for free, or become invited to your company account by one of your colleagues.
- Xcode 14 is required to to build iOS SDK.
- Respondent's device running iOS 12 or above.
Installation
There are three ways to install the Survicate Mobile SDK in the iOS applications:
Installing as Swift Package
The recommended installation method.
- Once your iOS application project is ready, open it in the Xcode and select your project’s Package Dependencies tab
- Copy the Survicate SDK Swift package repository URL
https://github.com/Survicate/survicate-ios-sdk
into the search field - Under the Dependency Rule, select the version of your preference.
- After the package download completes, select Add Package.
Survicate SDK should now be listed under Swift Package Dependencies in the Xcode Project Navigator.
Installing using CocoaPods
Define pod in your Podfile
and run pod install
.
Installing manually
- Download and extract the Survicate for iOS
- Drag Survicate.framework into your project. Make sure "Copy items if needed" is selected and click Finish.
- In the target settings for your app, set the Survicate.framework to “Embed & Sign”. You'll find it in the “Frameworks, Libraries, and Embedded Content” section of the “General” tab.
Configuration
The following configuration will require a Workspace Key. You can get your workspace key in the Access Keys section of the Survicate panel.
- Add workspace key to your
Info.plist
file.- Create
Survicate
Dictionary. - Define
WorkspaceKey
String inSurvicate
Dictionary. This is how yourInfo.plist
file should look like:
- Create
- Initialize the SDK using the
initialize
method. Choose an initialization method described below based on whether your project utilizes 'AppDelegate' class.
Make sure that import Survicate
line exists in all classes where you call SDK methods.
Survicate iOS SDK can be used in SwiftUI projects. If your SwiftUI project doesn't use the AppDelegate
class, the initialization of the Survicate Mobile SDK can be done in the constructor of the main application class:
As an alternative to the main way of specifying the Workspace Key, you can also use the setWorkspaceKey()
method.
Important:
- Using
setWorkspaceKey()
method overrides the Workspace Key defined in the configuration. setWorkspaceKey()
method must be used beforeinit()
method is called.
Using SDK
Survicate allows you to launch precisely targeted surveys inside your app. In Survicate Panel, you'll be able to define conditions that your users have to meet for the surveys to appear. Users matching conditions defined in the Survicate panel will see the survey automatically. Here's a list of conditions you can use to target your surveys:
- Name of the screen that a user currently sees
- Any application event
- User attributes and identities
- Device language
- Operating system
Make sure to list all the screens and events described in your application. Once you got this covered, you or any person responsible for creating and managing surveys will be able to trigger surveys from the Survicate panel with no need for you to update the application.
Warning The SDK utilizes UserDefaults to store information used by the targeting engine described in this section. Clearing UserDefaults will cause the targeting system to malfunction; f.e. by showing the same survey twice to a single user.
Targeting a survey by the screen name
A survey can appear when a user is viewing a specific screen. For example, a survey can be triggered to show up on the application's home screen after a user spends more than ten seconds there. To achieve that, you need to send information to Survicate about the user entering and leaving a screen.
Screen name is case sensitive. If there's any discrepancy between what's declared in the ‘Screens’ tab of the Target section in the Survicate panel and the application code, the survey will not appear.
Events-based survey targeting
You can log custom user events throughout your application. They can later be used in the Survicate panel to trigger your surveys. Your survey will show instantly after an event occurs in your app.
Event name and property keys are case sensitive. If there is any discrepancy between what's declared in the ‘Triggers’ tab of the Target section in the Survicate panel and the application code, the survey will not appear.
User identification & attributes
You can pass user attributes to Survicate as an additional layer of information about your users. Attributes can be used to:
- Identify respondents (by default survey responses are anonymous).
- Target surveys to specific users with Audience filters.
- Filter survey results.
- Recall information in survey questions (e.g. include user name).
Bear in mind that user attributes are cached, you only have to provide them once, e.g. when user logs in, not after each initialize()
. You can also change their values at any time (which may potentially trigger showing the survey).
Attribute types
- String: any text, e.g. user name or e-mail.
- Double: a decimal value.
- Boolean: a logic value.
- Date: a
Date
that can be used in date or time interval filters.
Special attributes
-
user_id: This corresponds to the "Logged-in status" in the panel's Audience filter. A user is considered logged-in when a trait with the "user_id" key has been set on the device, regardless of the value.
-
first_name, last_name, email: If none of these is specified, a response will be marked as Anonymous in the panel.
Additional notes
-
You can freely use custom attribute keys without the need to register them anywhere.
-
In some panel functionalities (e.g. autocompletion), the attribute key will be available only after a survey response with the given attribute is uploaded (unless the key was added in the panel manually). By that time, the trait is saved only locally on the user's device.
-
Note that the predefined attribute classes (
UserTrait.userId
,UserTrait.firstName
, etc.) have been deprecated in version 4.0. Instead, you should use theUserTrait(withName, value)
constructor. You will find migration details in the deprecation messages. -
In objective-c implementation you should use string values for every attribute type (e.g.
@"true"
for boolean attribute).
Reseting user data for testing purposes
If you need to test surveys on your device, reset()
method might be helpful. This method will reset all user data stored on your device (survey views, attributes, and information about answered surveys for the targeting engine).
Listeners
SDK allows you to utilize event listeners. You may find them useful to trigger actions in your application based on actions performed by respondents. Here's a list of events you can subscribe to:
- survey_displayed - occurs when survey is loaded and appears in the User Interface
- question_answered - occurs after a question is answered ( Survicate stores incomplete survey submissions )
- survey_closed - occurs when a user closes the survey using the close button
- survey_completed - occurs when a user finishes the survey.
SurvicateAnswer object properties (QuestionAnsweredEvent.answer)
Property | Type | Description |
---|---|---|
type | String | Answer type. One of: ['text', 'single', 'multiple', 'smiley_scale', 'rating', 'csat', 'numerical_scale', 'nps', 'date', 'form', 'matrix', 'button_close', 'button_next', 'button_link']. |
id | Integer | Answer ID. Applicable only for types: ['single', 'smiley_scale', 'csat', 'rating', 'numerical_scale']. |
ids | Integer[] | Selected answer IDs. Applicable only for type = ['multiple']. |
value | String? | Text representation of an answer, e.g. "Happy" for smiley scale. Not applicable for call-to-action answers: ['button_close', 'button_next', 'button_link']. |
Note: We currently support passing the id
, ids
and value
properties only for the cases enlisted in the table above. You can expect to stumble upon answer objects that consist only of the type
property.
Changelog
5.4.0 (2024-10-22)
- New
- Each question type except Welcome message, Date, and Thank you screen can be set as mandatory or optional.
- Improved
- Accessibility features for Matrix question, survey progress indicator, and navigation buttons.
5.3.0 (2024-09-12)
- New
- Once an event is invoked in the app, its name and property names are also sent to Survicate’s panel now. They will be shown as suggestions when a user configures event targeting of a survey.
5.2.0 (2024-09-04)
- New
- New conditions are available in event targeting:
- Time delay after event occurrence
- Number of event occurrences
- Time of the first occurrence
- Time of the last occurrence
- If multiple conditions are applied, all of them should be met for a survey to appear.
- Fixed
- Fixed an issue with submit button visibility in single choice question.
5.1.2 (2024-07-25)
- Improved
- More distinguishable emojis in the 3-choice Smiley scale.
- Fixed
- Excessive spacing between Smiley scale emojis in the 3-choice layout.
- Issue with non visible Submit button in multiple choice questions.
5.1.1 (2024-07-18)
- Fixed
- Issue with non-validating fields in form questions.
5.1.0 (2024-07-17)
- New
- Navigation buttons are available now. When enabled, your survey respondents can go back to the previous questions, see their selected answers, and change them if necessary.
- Fixed
- Propagating Matrix answer in
SurvicateAnswer.value
of event listener.
Configuration json will be printed in console only in verbose log level.
5.0.0 (2024-06-10)
- New
- Matrix question type added.
- Fixed
- An issue where
setUserTrait
cleared previously set user traits.
4.4.0 (2024-04-30)
- New
- New targeting option available - event properties. You can add multiple properties to one event and join them with either “or” or “and” operator.
4.3.1 (2024-03-26)
- Fixed
- Issue with non triggering questionAnswered delegate method.
4.3.0 (2024-03-26)
- New
- More flexible survey recurring options are available now. Now you can specify how many days / weeks / months / years should pass before the survey can appear again. It’s also possible to set after how many days / weeks / months / years the survey should stop recurring.
- If you run several mobile surveys, now you can use survey throttling settings to specify a time frame that should pass between showing them. Use global throttling to set the same time frame for all your mobile surveys. Or use the survey level throttling to override the global settings and specify a different period before showing a particular survey.
4.2.1 (2024-03-25)
- Fixed
- Issue with recursive display of non-recurring survey.
4.2.0 (2024-03-15)
- New
- New targeting filter is available - screen orientation (portrait mode or landscape mode targeting). You can either include or exclude one of the orientation modes.
- SDK now supports ISO 8601 date format with milliseconds.
4.1.1 (2024-02-15)
- Fixed
- Properties of the models in the listener are available within Objective-C.
4.1.0 (2024-02-08)
- New
- Events like
onSurveyDisplayed
,onQuestionAnswered
,onSurveyClosed
, andonSurveyCompleted
now utilize specific event objects:SurveyDisplayedEvent
,QuestionAnsweredEvent
,SurveyClosedEvent
,SurveyCompletedEvent
.
The SDK now supports the registration of multiple event listeners.
4.0.2 (2024-01-22)
- Fixed
- An issue where Thank you screen don't close survey in classic theme
4.0.1 (2024-01-09)
- Improved
- Date format in user traits recalling
- Fixed
- A bug where users could see survey more times than specified in recurrence settings if SDK was updated in meantime
4.0.0 (2023-11-30)
- New
- User conditions targeting is changed to the audience targeting: create an audience that will be available for usage among all your mobile surveys.
- Enable multiple audiences at the same time in one survey if necessary.
- User attributes now support not only string values but also numbers, boolean, and datetime values.
- New attribute operators are available to support new data types.
- Survey audience can be set not only by including a set of respondents who met the required criteria but also by excluding those who should not see the survey.
- And / or operators in audience targeting are switchable now: within one attribute filter that has several attributes in it and between different filters.
3.0.4 (2023-09-28)
- Fixed
- Issue where surveys were not translated when app language was set to dialect.
3.0.3 (2023-09-27)
- Fixed
- Issue where rating scale question answer ID was missing in listener.
3.0.2 (2023-08-21)
- Improved
- Not displaying surveys when alerts are visible.
3.0.1 (2023-07-31)
- Fixed
- Issue with displaying a survey in workspaces with multiple recurring surveys despite meeting all the conditions.
3.0.0 (2023-07-25)
- New
- New logic settings have been added to all question types (except Welcome message, Date and Thank you screen).
- Fixed
- Issue with keyboard animations.
2.4.0 (2023-07-11)
- New
- Now it's possible to select how to position answer choices in the NPS question: vertically (default option) or horizontally.
- Fixed
- An issue with the first question being displayed incorrectly.
2.3.1 (2023-06-06)
- Fixed
- An issue when it was not possible to filter survey responses by language in the panel.
An issue where after synchronization failure the SDK was not respecting refresh interval.
An issue where submit button on iPad was not displayed correctly.
2.3.0 (2023-05-25)
- New
- Now while adding introduction or question texts you can recall information from attributes passed to Survicate or from answers to other questions in the survey.
2.2.1 (2023-05-9)
- Fixed
- Assigning answers to the wrong survey within the same workspace.
2.2.0 (2023-05-4)
- New
- Surveys can be translated into an app language if a corresponding translation is added in the panel.
2.1.2 (2023-04-24)
- Fixed
- Bug that caused a crash when calling SDK on multiple threads.
2.1.1 (2023-04-12)
- Fixed
- Visible hyphen even in the absence of a label in NPS and rating scale.
2.1.0 (2023-04-06)
- New
- Rating question type added.
Question and introduction texts can be made bold, italics, or hyperlinked.
2.0.2 (2023-03-20)
- Fixed
- Special characters encoding issue.
2.0.1 (2023-03-14)
- Fixed
- Disabled dismiss on overlay tap.
2.0.0 (2023-03-09)
- New
- 21 new design themes.
2 new survey settings - “Progress bar” and “Remove Survicate branding”.
New customization options: add a company's logo or a survey sender's avatar and a greeting message from them.
1.8.10 (2023-02-9)
- Improved
- Accuracy of survey sampling.
- Fixed
- Code causing priority inversion warning to be displayed.
1.8.9 (2023-01-24)
- Fixed
- Language detection issues.
1.8.8 (2023-01-1)
- Update
- Remove character limit from text fields.
1.8.7 (2022-12-6)
- Fixed
- An issue of not showing the survey on dismissing the view controller.
1.8.6 (2022-12-5)
- Fixed
- Problem with truncating endings in long answer texts.
1.8.5 (2022-11-22)
- Fixed
An issues causing a survey to be displayed repeatedly, when using a delayed display feature.
1.8.4 (2022-11-16)
- Fixed
A possible race condition when multiple SDK methods are called at the same time.
1.8.3 (2022-09-03)
- Fixed
An issue causing NPS button labels to be displayed in incorrect colors.
- Changed
The minimum iOS version requirement for the respondent's device is now iOS 12.
1.8.2 (2022-08-05)
- Fixed
- Layout fixes for large displays.
- Fixed
- Answers for smiley scale questions could be not stored.
1.8.1 (2022-06-14)
- Fixed
- Tracking the SDK version for internal purposes.
1.8.0 (2022-05-19)
- New
Detailed answer value for the Smile scale question is provided in the Question answered event listener.
1.7.3 (2022-05-10)
- Fixed
- Survey layout issues.
1.7.1 (2022-04-05)
- Fixed
- Memory leaks.
1.7.0 (2022-03-22)
- New
Survicate Mobile SDK can now be integrated using Swift Package Manager.
Please refer to the installation documentation to see, how to integrate Survicate Mobile SDK using Swift Package Manager.
1.6.7 (2022-03-15)
- Updated
Improved UI rendering speed, we fixed minor layout glitches and some memory leaks.
1.6.6 (2022-03-08)
- Fixed
- UI rendering speed and layout glitches.
1.6.5 (2022-02-23)
- Fixed
- Memory leaks and UI rendering speed.
1.6.4 (2022-02-16)
- Fixed
When setting the survey to appear to less than 1% of targeted users, the survey was not displayed. In general, the audience sampling feature in the targeting engine had issues with interpreting numbers with decimal points.
1.6.3 (2022-02-04)
- Fixed
In some cases survey settings (TTL) mechanism was not refreshed correctly.
- Updated
- Survey settings Time to Live(TTL) reduced to 10 minutes.
1.6.2 (2022-01-26)
- Fixed
The
setWorkspaceKey()
method is now working properly, as described in the documentation.
1.6.1 (2021-12-08)
- Updated/Fixed
The minimum Xcode version required to run Survicate Mobile SDK is now: 12.5.1
1.6.0 (2021-11-18)
- New
Surveys can now be set to appear on a recurring basis. This means respondents can answer the same mobile survey again, and again - on a daily, weekly, monthly, or quarterly basis.
1.5.8 (2021-10-26)
- New
- Scale labels can now be displayed below the smiley scale question
1.5.7 (2021-10-21)
- New
Survey settings Time to Live(TTL) mechanism on respondent's device. The mechanism ensures that the survey settings are up to date on the respondent's side. If the current version of survey settings is older than 60 minutes, the survey configuration is checked for updates.
1.5.6 (2021-09-29)
- New
The method
setWorkspaceKey()
allows to specify Survicate workspace key from code.
1.5.5 (2021-08-26)
- Fixed
Locales used by SDK were improved to resolve issue related to warning WARNING ITMS-90176 appearing during upload the app using SDK to the AppStore
1.5.4 (2021-08-26)
- Fixed
We restored the minimum iOS version required for the SDK to work to 10.0.
1.5.3 (2021-08-23)
- Updated
Survicate iOS SDK is now distributed as an XCFramework binary, making the SDK compatible with Swift 5.x. As a result, the main class of Survicate Mobile SDK had to be renamed.
The version 1.5.3 of the Survicate iOS SDK introduces support for binary framework, which causes a minor backward compatibility break. Until the version 1.5.3 the main SDK class was called
Survicate
, in the version 1.5.3 that class was renamed toSurvicateSdk
. The change was introduced to make it possible to distribute Survicate Mobile SDK as the XCFramework binary.
1.5.2 (2021-07-23)
- Fixed
- Support for using the Survicate Mobile SDK with Swift 5.x
1.5.1 (2021-06-24)
- Updated
- Provides support for using the Survicate Mobile SDK with Swift 5.4.1
1.5.0 (2021-06-15)
- New
Multiple choice question are shown as checkboxes instead of radio buttons
- SDK uses currently respondent API v3 endpoints
- Fixed
The
cornerRadius
extension was renamed in order to avoid conflict in apps that would use SDK
1.4.5 (2021-04-28)
- Updated
- Supported Swift version 5.4.
1.4.4 (2021-04-19)
- Fixed
An issue that caused targeting by attributes to malfunction in some cases.
1.4.3 (2020-12-02)
- Updated
- Supported Swift version 5.3.1.
1.4.2 (2020-09-23)
- Updated
- Supported Swift version 5.3.
1.4.1 (2020-09-22)
- New
It’s now possible to suppress a survey if other was answered during the current visit to your app.
1.4.0 (2020-04-22)
- Updated
Unnecessary spacing on the left side of the question has been removed.
- Fixed
- Proper handling of 4xx error codes.
- Fixed
A bug causing surveys not to appear when targeted only at logged in users.
- Fixed
A minor issue causing the survey not to appear when targeted at multiple values of the same attribute.
1.3.2 (2020-04-01)
- Updated
- Supported Swift version 5.2.
1.3.1 (2020-02-11)
- Fixed
- SDK listeners - answer object minor fixes.
1.3.0 (2020-01-23)
- New
- SDK now supports listeners.
1.2.0 (2019-12-19)
- Fixed
- Survey ends after Thank you message and CTA.
- New
- SDK now supports survey completion rate.
1.1.5 (2019-10-11)
- Fixed
- Surveys layout leaned on right column.
1.1.4 (2019-09-25)
- Updated
- Supported Swift version 5.1.
1.1.3 (2019-09-10)
- Updated
- SDK now supports new installation flow.
1.1.2 (2019-08-08)
- Fixed
- Skip-logic wasn't functioning properly in some cases.
- Fixed
reset()
method didn't clear user attributes.
1.1.0 (2019-04-05)
- Updated
- Supported Swift version 5.0.
1.0.8 (2019-03-19)
- Fixed
- Surveys were sometimes shown on a wrong 'ViewController'.
1.0.7 (2019-01-30)
- Fixed
UserTrait
default constructor was missing.