iOS SDK
Anecdote iOS SDK
This package will help you integrate Anecdote into your app.
Installation
Swift Package Manager
Currently we only support the Swift Package Manager.
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.
Then you'll want to depend on the Anecdote
target:
Integration
You can create an instance of Anecdote object by providing your environment ID and the zone and use that instance moving forward.
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:
Setting attributes
User object provides subscript
to easily set attributes and setting any attribute to nil removes it:
Email has a dedicated property so either way of setting it is the same:
Language also has a dedicated property and can be set either by using the provided enum or by providing an arbitrary string:
Logout or removing the user
Just set the user
property of anecdote
to 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).
Last updated