🐘
Anecdote Docs
  • Getting started
  • Integrations
    • Gorgias
    • SurveyMonkey
    • Zendesk
    • SendBird
    • Freshdesk
    • Intercom
    • Kustomer
    • HubSpot
    • Typeform
    • Delighted
    • Android SDK
    • iOS SDK
  • Release Notes
  • On-Prem Setup
    • Getting started
    • Identifying the Need for On-Prem Setup
    • Strategy for Client-Side Data Collection and Processing
    • Architecture Overview
    • Why Airbyte and Its Technical Details
    • Custom Airbyte Destination Development and Specifications
    • Health Check Monitoring
  • Direct Data Injection EndPoint
    • Introduction
    • Getting Started
    • Authorization
    • Data Format
    • Error Handling
Powered by GitBook
On this page
  • Anecdote iOS SDK
  • Installation
  • Integration
  • User Management
  • Event Tracking
  1. Integrations

iOS SDK

PreviousAndroid SDKNextRelease Notes

Last updated 6 months ago

Anecdote iOS SDK

This package will help you integrate Anecdote into your app.

Installation

Swift Package Manager

Currently we only support the .

Once you have your Swift package set up, adding Anecdote as a dependency is as easy as adding it to the dependencies value of your Package.swift or the Package list in Xcode.

dependencies: [
    .package(url: "https://github.com/Anecdote-AI/anecdote-ios-sdk", .upToNextMajor(from: "0.1.0"))
]

Then you'll want to depend on the Anecdote target:

.product(name: "Anecdote", package: "Anecdote")

Integration

You can create an instance of Anecdote object by providing your environment ID and the zone and use that instance moving forward.

let anecdote = Anecdote(envID: <#ENV_ID#>, zone: <#Zone#>)

User Management

User attributes and event tracking are the main use cases of the SDK and user is an optional property of Anecdote. User has a failable initializer because it has a requirement of a non-empty String to be passed to identify a user. The user object is persisted locally.

Create and set the user for the first time:

anecdote.user = User(id: <#UserID#>, email: <#Email#>, attributes: <#Additional Attributes#>)

// Or just this as `email` and `attributes` have default values
anecdote.user = User(id: <#UserID#>)

Setting attributes

User object provides subscript to easily set attributes and setting any attribute to nil removes it:

anecdote.user?["city"] = <#City#> 

Email has a dedicated property so either way of setting it is the same:

anecdote.user?.email = <#Email#>

// Same as
anecdote.user?["email"] = <#Email#>

Language also has a dedicated property and can be set either by using the provided enum or by providing an arbitrary string:

anecdote.user?.language = <#LanguageEnum#>
anecdote.user?["language"] = <#LanguageString#>

Logout or removing the user

Just set the user property of anecdote to nil:

anecdote.user = nil

Event Tracking

There times where you need to track specific events or actions the user takes which would be stored locally. All you have to do is just provide a string value for the eventName which would be trimmed (empty or whitespace-only strings are ignored).

anecdote.track(<#EventName#>)
Swift Package Manager