Skip to main content

iOS SDK

The JourneyLayer iOS SDK is a Swift library (current version 1.1.0) that tracks events, identifies users, and powers on-device capabilities such as push notifications, in-app messages, and deep links.

It exposes the same three core methods you know from the web: track, identify, and reset.

Source of truth

This page gets you installed and sending events. For the exact, current initialization signature and the push / in-app / deep-link APIs, always confirm against the iOS SDK source on GitHub. We keep the in-repo README authoritative so you never copy a stale signature.

Installation

In Xcode, choose File -> Add Packages... and enter the repository URL:

https://github.com/digitalgw/journeylayer

Then select the JourneyLayer iOS package product and pin version 1.1.0 (or later). The package is defined by a root Package.swift in the repository.

If you manage dependencies in your own Package.swift, add it as a dependency:

dependencies: [
.package(url: "https://github.com/digitalgw/journeylayer", from: "1.1.0")
]
Confirm the package product name

The URL above is illustrative. Confirm the exact package product / target name and the latest version in the iOS SDK README.

CocoaPods

The SDK also ships a CocoaPods podspec. If your project uses CocoaPods, add the pod to your Podfile and run pod install. See the iOS SDK README for the exact pod name and version.

Initialization

Initialize the SDK once, early in your app lifecycle (typically in your AppDelegate's application(_:didFinishLaunchingWithOptions:) or your SwiftUI App init). You need three things:

  • Project ID — your project's public ID, from the dashboard.
  • Publishable token — the publishable browser/mobile token. This is safe to embed in your app config.
  • Events endpoint — defaults to https://collect.journeylayer.com/v1/events, or your first-party tracker domain (e.g. https://track.yourdomain.com/v1/events) if you've set one up.
import JourneyLayer

JourneyLayer.initialize(
projectId: "<PROJECT_PUBLIC_ID>",
token: "<PUBLISHABLE_TOKEN>",
endpoint: "https://collect.journeylayer.com/v1/events"
)
Use the publishable token only

Embed the publishable browser/mobile token in your app. Never ship the server project token in a mobile binary — it can be extracted from the app bundle.

Confirm the init signature

The snippet above is illustrative. The exact parameter names and any configuration object are defined in the iOS SDK README.

Track events

Record a custom event with track(name, properties). Event names are free-form and auto-register on the server, so there's no schema to define first.

JourneyLayer.track(
"Product Viewed",
properties: [
"product_id": "SKU-123",
"price": 1499,
"currency": "INR"
]
)
  • name — a human-readable string. Title Case (Product Viewed) is a good convention.
  • properties — a dictionary of JSON-serializable values. Send whatever you'll want to segment and filter on later.

Identify users

Tie the current device to a known person with identify(traits). Call it once you know who the user is, for example right after login.

JourneyLayer.identify([
"identity": "[email protected]", // stable id, usually email
"email": "[email protected]",
"name": "Kishan",
"phone": "+91 9999999999"
])

The stable identity stitches the device's earlier anonymous activity to the known user.

Reset on logout

Call reset() on logout so the next user on a shared device isn't merged into the previous one. It clears the identity and starts a fresh anonymous id.

JourneyLayer.reset()

Next