Skip to main content
The Tranthor iOS SDK is a Swift package with no third-party dependencies. It sends identify, track, page and screen events from your app, keeps them on disk until they are delivered, and, with its optional push module, registers the iPhone for mobile push. It needs iOS 15 or later.

Installation

The package has three products. Add the ones you need to your app:
The iOS SDK is not in a public package registry yet. Contact us at support@tranthor.com for access to the Swift package.

Usage

Create one instance and keep it for the life of the app. Each call returns once the event is saved on the phone. It does not wait for the network, so calls stay fast and events survive the app being closed.

Methods

anonymousId, userId and isOptedOut read the current state. Every event method also takes optional userId, anonymousId, messageId, timestamp and context arguments. Numbers are sent as doubles, so send identifiers larger than 2^53 as strings.

Identity

Before identify, events carry an anonymous id that the SDK creates and stores on the phone. After identify, events carry the user id.
  • The identify call sends both the user id and the anonymous id, which lets Tranthor attach the customer’s earlier anonymous activity to them.
  • If a different customer identifies on the same phone, the SDK first replaces the anonymous id with a new one. The second customer never inherits the first customer’s anonymous activity.
  • An empty userId is treated as no user id.
  • reset() clears the user id and starts a new anonymous id.
optOut() discards everything queued and ignores later calls until optIn(). While opted out, flush() returns without sending anything. If the phone is registered for push, opting out also tells Tranthor to stop sending push to it.

Configuration

Configuration takes these options:

Delivery

  • Events are sent in batches. Network errors and HTTP 408, 425, 429 and 5xx responses are retried, and a Retry-After header is honoured up to 30 seconds. Other statuses, such as an invalid write key (401), are dropped after one attempt and reported through onError.
  • Queued events are stored on the phone and sent after a restart. The files are kept out of backups.
  • The SDK sends what is queued when the app goes to the background and resumes when it returns.
  • With the default settings a batch is dropped after about 15 seconds of failed attempts. An app that stays offline longer than that can lose events.

Push

To send push to the app, add TranthorPush and follow Set up iOS. The push module uses the same instance, write key and queue, so identify, reset, optOut and optIn keep the phone’s registration in step with no extra calls. A phone is registered only while a customer is signed in: identify registers it and reset() removes it (Who a phone belongs to).

Current limits

  • No automatic screen tracking.
  • No subscribe and unsubscribe methods. Use the API or the Web SDK for those.
  • The package is not in a public registry yet.