|
| 1 | +--- |
| 2 | +title: 1Flow Swift Plugin |
| 3 | +--- |
| 4 | + |
| 5 | +[1Flow](https://1flow.ai/?utm_source=segmentio&utm_medium=docs&utm_campaign=partners){:target="_blank"} is a leading in-app user survey and messaging platform for Mobile app and SaaS businesses. |
| 6 | + |
| 7 | +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. |
| 8 | + |
| 9 | +## Getting started |
| 10 | + |
| 11 | +1. From the Segment web app, click **Catalog**, then search for **1Flow Mobile Plugin**. |
| 12 | +2. Click **Add Destination**. |
| 13 | +4. Select an existing Source to connect to 1Flow Mobile Plugin. |
| 14 | +5. Go to **1flow.ai > Settings > Project Settings**, copy the 1Flow project key, and paste it into the Destination Settings in Segment. |
| 15 | +6. Depending on the mobile source you’ve selected, include 1Flow's library by adding the following lines to your dependency configuration. |
| 16 | + |
| 17 | +## Adding the dependency |
| 18 | + |
| 19 | +### Through Xcode |
| 20 | + |
| 21 | +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. |
| 22 | +``` |
| 23 | +https://github.com/1Flow-Inc/segment-1flow-ios.git |
| 24 | +``` |
| 25 | + |
| 26 | + |
| 27 | +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**. |
| 28 | + |
| 29 | +### Through Package.swift |
| 30 | + |
| 31 | +Open your Package.swift file and add the following to the `dependencies` section: |
| 32 | + |
| 33 | +``` |
| 34 | +.package( |
| 35 | + name: "Segment", |
| 36 | + url: "https://github.com/1Flow-Inc/segment-1flow-ios.git", |
| 37 | + from: "1.0.0" |
| 38 | + ), |
| 39 | +``` |
| 40 | + |
| 41 | +## Using the Plugin in your app |
| 42 | + |
| 43 | +Open the file where you set up and configure the Analytics-Swift library. Add this plugin to the list of imports. |
| 44 | + |
| 45 | +``` |
| 46 | +import Segment |
| 47 | +import SegmentOneFlow // <-- Add this line |
| 48 | +``` |
| 49 | + |
| 50 | +Just under your Analytics-Swift library setup, call `analytics.add(plugin: ...)` to add an instance of the plugin to the Analytics timeline. |
| 51 | + |
| 52 | +``` |
| 53 | +let analytics = Analytics(configuration: Configuration(writeKey: "<YOUR WRITE KEY>") |
| 54 | + .flushAt(3) |
| 55 | + .trackApplicationLifecycleEvents(true)) |
| 56 | +analytics.add(plugin: OneFlowDestination()) |
| 57 | +``` |
| 58 | + |
| 59 | +## Identify |
| 60 | +If you're not familiar with the Segment Specs, take a look to understand what the [Identify method](/docs/connections/spec/identify/) does. An example call would look like: |
| 61 | + |
| 62 | +```swift |
| 63 | +analytics. identify( userId: "[email protected]", traits: [ |
| 64 | + "name": "Peter Gibbons", |
| 65 | + |
| 66 | + "mobile": 1234567890 |
| 67 | +]) |
| 68 | +``` |
| 69 | +The Segment identify method is equivalent to `logUser` of 1Flow. `userId` will be `userID` and `traits` will be `userDetails`. |
| 70 | + |
| 71 | +## Track |
| 72 | +If you're not familiar with the Segment Specs, take a look to understand what the [Track method](/docs/connections/spec/track/) does. An example call would look like: |
| 73 | + |
| 74 | +```swift |
| 75 | +analytics.track(name: "ButtonClicked") |
| 76 | +``` |
| 77 | +Any value passed in `name`, will be eventName and if you have passed any event property, then it will be event `parameters`. |
| 78 | + |
| 79 | +## Screen |
| 80 | + |
| 81 | +Send [Screen](/docs/connections/spec/screen) calls to record which mobile app screens users have viewed. For example: |
| 82 | + |
| 83 | +```swift |
| 84 | +analytics.screen(title: "Home") |
| 85 | +``` |
| 86 | + |
| 87 | +Segment sends Screen calls to 1Flow as a `screen_[name]` event (or `screen_view` if a screen name isn't provided). |
0 commit comments