Engage helps businesses deliver personalized customer messaging and marketing automation through email, SMS and in-app messaging. This iOS SDK makes it easy to identify customers, sync customer data (attributes, events and device tokens) to the Engage dashboard and send in-app messages to customers.
- Track device token
- Identify users
- Update user attributes
- Track user events
- Create an Engage account and set up an account to get your public API key.
- Learn about connecting customer data to Engage.
The SDK is available via SPM or Cocoapods.
- In Xcode, go to your project’s Package Dependencies section.
- Click the + button to add a new package.
- Enter the following URL:
https://github.com/engage-so/engage-ios.git
- Choose the version you want to install, and add it to your project.
- Add the Engage SDK to your
Podfile
:
platform :ios, '13.0'
target 'YourAppTarget' do
use_frameworks!
pod 'Engage-swift', :git => 'https://github.com/engage-so/engage-ios.git', :tag => 'v1.0.0'
end
- Install the dependencies by running:
pod install
If you are using Swift Package Manager programmatically in a Package.swift
file:
dependencies: [
.package(url: "https://github.com/engage-so/engage-ios.git", from: "1.0.0")
]
Import Engage
and initialize the SDK.
// ...
import Engage
@main
struct MainApp: App {
init() {
Engage.shared.initialise(publicKey: "public-api-key")
}
// ...
}
Engage uses your user's unique identifier (this is mostly the ID field of the users' table) for data tracking. Identify lets you link this ID to the user. With identify, you are able to supply more details about the user.
let properties = ["first_name": "Jane", "last_name": "Doe", "last_login": Date()]
Engage.shared.identify(uid: "user-id", properties: properties)
Engage supports the following standard attributes: first_name
, last_name
, email
, number
(customer's phone number) but you can use identify to add any customer attribute you want. last_login
in the example above is an example.
When new users are identified, Engage assumes their signup date to be the current timestamp. You can change this by adding a created_at
attribute.
let properties = ["first_name": "Jane", "last_name": "Doe", "created_at": "2021-01-04"]
Engage.shared.identify(uid: "user-id", properties: properties)
To add more attributes to the user's profile, use the addAttributes
method.
let attributes = ["plan": "Pro", "age": 14]
Engage.shared.addAttributes(properties: attributes, uid: "optional")
Engage integrates with FCM to let you send push notifications to your users, either through broadcast or automation. However, to do this, you need to send the user's FCM registration token to Engage. The device registration token is a unique identifier that allows the device receive messages.
func onNewToken(token: String) {
Engage.shared.setDeviceToken(deviceToken: token, uid: "optional")
}
Track an event:
Engage.shared.track(event: "Login", uid: "optional")
Track an event with a value:
Engage.shared.track(event: "Clicked", value: "Login button", uid: "optional")
Track an event with properties:
let properties = ["type": "button", "counter": counter]
Engage.shared.track(event: "Clicked", value: properties, uid: "optional")
Engage sets the event date to the current timestamp but if you would like to set a different date, you can add a date as an argument in the track
method.
Engage.shared.track(event: "Clicked", value: "Login button", date: Date(), uid: "optional")