iOS SDK
Last updated
Last updated
This package will help you integrate Anecdote into your app.
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.
Then you'll want to depend on the Anecdote
target:
You can create an instance of Anecdote object by providing your environment ID and the zone and use that instance moving forward.
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.
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:
Just set the user
property of anecdote
to nil:
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).