Skip to contentSkip to navigationSkip to topbar
On this page
Looking for more inspiration?Visit the
(information)
You're in the right place! Segment documentation is now part of Twilio Docs. The content you are used to is still here—just in a new home with a refreshed look.

1Flow Swift Plugin


1Flow(link takes you to an external page) is a leading in-app user survey and messaging platform for Mobile app and SaaS businesses.

Using 1Flow, you can reach users in-the-moment while they are interacting with your website or application to collect highly contextual user insights that help you improve your product offering and customer experience.


Getting started

getting-started page anchor
  1. From the Segment web app, click Catalog, then search for 1Flow Mobile Plugin.
  2. Click Add Destination.
  3. Select an existing Source to connect to 1Flow Mobile Plugin.
  4. Go to 1flow.ai > Settings > Project Settings, copy the 1Flow project key, and paste it into the Destination Settings in Segment.
  5. Depending on the mobile source you've selected, include 1Flow's library by adding the following lines to your dependency configuration.

Through Xcode

through-xcode page anchor

In the Xcode File menu, click Add Packages. You'll see a dialog where you can search for Swift packages. In the search field, enter the URL to this repository.

https://github.com/1Flow-Inc/segment-1flow-ios.git

You'll then have the option to pin to a version, or specific branch, as well as which project in your workspace to add it to. Once you've made your selections, click Add Package.

Open your Package.swift file and add the following to the dependencies section:

1
.package(
2
name: "Segment",
3
url: "https://github.com/1Flow-Inc/segment-1flow-ios.git",
4
from: "1.0.0"
5
),

Using the Plugin in your app

using-the-plugin-in-your-app page anchor

Open the file where you set up and configure the Analytics-Swift library. Add this plugin to the list of imports.

1
import Segment
2
import SegmentOneFlow // <-- Add this line

Just under your Analytics-Swift library setup, call analytics.add(plugin: ...) to add an instance of the plugin to the Analytics timeline.

1
let analytics = Analytics(configuration: Configuration(writeKey: "<YOUR WRITE KEY>")
2
.flushAt(3)
3
.trackApplicationLifecycleEvents(true))
4
analytics.add(plugin: OneFlowDestination())

Here's an example of the Identify method:

1
analytics.identify(userId: "peter@example.com", traits: [
2
"name": "Peter Gibbons",
3
"email": "peter@example.com",
4
"mobile": 1234567890
5
])

The Segment Identify method is equivalent to 1Flow's logUser. Segment's userId is mapped to 1Flow's userID and Segment's traits are mapped to 1Flow's userDetails.


Here's an example of the Track method:

analytics.track(name: "ButtonClicked")

Any value you pass in the name parameter is set as eventName in 1Flow. If you pass any event properties, you can find them in 1Flow's parameters event.


Send Screen calls to record which mobile app screens users have viewed. For example:

analytics.screen(title: "Home")

Segment sends Screen calls to 1Flow as a screen_[name] event (or screen_view if a screen name isn't provided).