iOS SDK API Reference
The Capillary iOS SDK APIs provide you with the capability to perform various actions, including customer registrations, customer logins, and more. These APIs can also be used for reporting to track events such as customer registrations, customer logins, and more.
There are 2 types of events:
- Standard events - These events are configured in the SDK and cannot be removed. With Capillary SDK, you can record user-specific information such as their username, first name, last name, email, mobile number, and other custom information, along with system information, in the events. This information can then be used to run campaigns based on user segregation at different levels.
- Behavioural events - The events resource also allows you to create behavioural events to track any other important user interactions for your business. For example, events such as forgot password, cart abandonment, etc. These events can be further defined by event attributes such as price, quantity, and category. These events need to be configured in your org settings.
For behavioural events, you need to do configuration in the Hydraconfig and organisation settings.
Sending standard events to SDK
Sign In
This API can be used to sign in a user to the platform and report when a user signs in.
public func reportUserSignIn(data: UserSignInGenerator, customData: Attributes)
UserSignInGenerator
: This object holds the necessary basic information. You can generate this object by organizing the required information into a suitable container or object that adheres to theUserSignInGenerator
protocol.customData
(Optional): This allows adding any extra information or custom data associated with the event being reported. The custom data should be added in the format of aDictionary<String, Any>
.
Parameters | Type | Description | Mandatory/Optional |
---|---|---|---|
firstName | String | User first name | Mandatory |
lastName | String | User last name | Mandatory |
String | User email address | Optional | |
phone | String | User mobile number | Mandatory |
customData | Dictionary | Additional information associated with the event being reported. | Optional |
Example 1: SignIn event with emptycustomData
parameter.
let userSignInData = UserSignInData(firstName: "first-name", lastName: "last-name", email: "[email protected]", phone: "xxxxxxxx")
hydraCore.reportUserSignIn(data: userSignInData, customData: [:])
Example 2: SignIn event with customData
attributes age and gender. This allows for the logging of specific attributes related to the user's age and gender during the user sign-in report.
let userSignInData = UserDetails(firstName: "first-name", lastName: "last-name", email: nil, phone: "xxxxxxxx")
hydraCore.reportUserSignIn(data: userSignInData, customData: [“Age”: “25”, “Gender”: “Male”])
Example 3: SignIn event with customData
attributes age, gender and email.
let userSignInData = UserSignInData(firstName: "first-name", lastName: "last-name", email: "[email protected]", phone: "xxxxxxxx")
hydraCore.reportUserSignIn(data: userSignInData, customData: [“Age”: “25”, “Gender”: “Male”])
Sign Up
This API can be used to register a user to the platform and report when a user registers.
public func reportUserSignUp(data: UserSignUpGenerator, customData: Attributes)
UserSignUpGenerator
: This object holds the necessary basic information. You can generate this object by organizing the required information into a suitable container or object that adheres to theUserSignUpGenerator
protocol.customData
(Optional): This allows adding any extra information or custom data associated with the event being reported. The custom data should be added in the format of aDictionary<String, Any>
.
Parameters | Type | Description | Mandatory/Optional |
---|---|---|---|
firstName | String | User first name | Mandatory |
lastName | String | User last name | Mandatory |
String | User email address | Optional | |
phone | String | User mobile number | Mandatory |
customData | Dictionary | Additional information associated with the event being reported. | Optional |
Example 1: SignUp event with emptycustomData
parameter.
let userSignUpData = UserSignUpData(firstName: "first-name", lastName: "last-name", email: "[email protected]", phone: "xxxxxxxx")
hydraCore.reportUserSignUp(data: userSignUpData, customData: [:])
Example 2: SignUp event with customData
attributes age and gender. This allows for the logging of specific attributes related to the user's age and gender during the user sign-in report.
let userSignUpData = UserDetails(firstName: "first-name", lastName: "last-name", email: nil, phone: "xxxxxxxx")
hydraCore.reportUserSignUp(data: userSignUpData, customData: [“Age”: “25”, “Gender”: “Male”])
Example 3: SignUp event with customData
attributes age, gender and email.
let userSignUpData = UserSignUpData(firstName: "first-name", lastName: "last-name", email: "[email protected]", phone: "xxxxxxxx")
hydraCore.reportUserSignUp(data: userSignUpData, customData: [“Age”: “25”, “Gender”: “Male”])
User profile update
This API can be used to update a user's profile and report when a user has updated their profile.
public func reportUserProfileUpdate(data: UserProfileUpdateGenerator, customData: Attributes, subscriptions: [Any]? = nil)
UserProfileUpdateGenerator
: This object holds the necessary basic information. You can generate this object by organizing the required information into a suitable container or object that adheres to theUserProfileUpdateGenerator
protocol.customData
(Optional): This allows adding any extra information or custom data associated with the event being reported. The custom data should be added in the format of aDictionary<String, Any>
.
Parameters | Type | Description | Mandatory/Optional |
---|---|---|---|
firstName | String | User first name | Optional |
lastName | String | User last name | Optional |
String | User email address | Optional | |
phone | String | User mobile number | Optional |
customData | Dictionary | Additional information associated with the event being reported. | Optional |
subscriptions | Array | The subscriptions list for the logged in user. | Optional |
Example 1: User profile update event with emptycustomData
parameter.
let userProfileUpdateData = UserProfileUpdateData(firstName: "first-name", lastName: "last-name", email: "[email protected]", phone: "xxxxxxxx")
hydraCore.reportUserProfileUpdate(data: userProfileUpdateData, customData: [:])
Example 2: User profile update with customData
attributes age and gender. This allows for the logging of specific attributes related to the user's age and gender during the user sign-in report.
let userProfileUpdateData = UserProfileUpdateData(firstName: "first-name", lastName: "last-name", email: "[email protected]", phone: "xxxxxxxx")
hydraCore.reportUserProfileUpdate(data: userProfileUpdateData, customData: [“Age”: “25”, “Gender”: “Male”])
Example 3: User profile update event with subscription
parameter.
var subscriptions: [HydraSubscription] = []
var subscription: HydraSubscription = HydraSubscription(channel: "EMAIL", priority: "BULK", type: "OPTIN")
subscriptions.append(subscription)
subscription = HydraSubscription(channel: "PUSH", priority: "BULK", type: "OPTIN")
subscriptions.append(subscription)
let userProfileUpdateData = UserDetails(firstName: "first-name", lastName: "last-name", email: "[email protected]", phone: "xxxxxxxx")
hydraCoreSDK.reportUserProfileUpdate(data: userProfileUpdateData, customData: [:], subscriptions: subscriptions)
Sign Out
This API can be used to sign out a user and report when a user has signed out.
public func reportUserSignOut(customData: [String: Any])
To log sign-out events, you can call the API without providing any data. This action removes all the user-related basic information, such as first name and mobile number, that was previously provided in the session.
Example
hydraCore.reportUserSignOut(customData: [:])
Sending behavioural events to SDK
These events can be used to track user actions throughout the application. These events are valid only if the SDK receives the SignIn
or SignUp
events. Events are Invalid if they are called after a SignOut
event. In order to track these events, users have to pass event names (NotNull or NonEmpty) and attributes (optional).
The API below enables the application to send the custom events:
public func reportBehavioralEvent(name: String, customAttributes attributes: Attributes)
Parameter | Type | Description | Mandatory/Optional |
---|---|---|---|
event_name | String | Name of the event | Compulsory |
attributes | Dictionary | The custom attributes map for the events | Optional |
Example:
hydraCore.reportBehavioralEvent(name: "event-name",
customAttributes: ["additional-info" : "additional-details",
["additional-info" : "additional-details"])
Updated 5 days ago