Skip to content

AdevintaSpain/braze-segment-swift

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Braze-Segment-Swift

Add this plugin to your applications to support both the Segment Analytics-Swift SDK and the Braze Swift SDK.

Adding the dependency

via Xcode

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 repo.

https://github.com/braze-inc/braze-segment-swift

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

via Package.swift

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

.package(
  url: "https://github.com/braze-inc/braze-segment-swift",
  from: "2.0.0"
),

Update your target dependencies to include either SegmentBraze or SegmentBrazeUI:

.target(
  name: "...",
  dependencies: [
    .product(name: "Segment", package: "analytics-swift"),
    .product(name: "SegmentBraze", package: "braze-segment-swift"),
  ]
),

Note: SegmentBraze does not provide any UI components and does not depend on BrazeUI. If you need UI components, use SegmentBrazeUI in place of SegmentBraze – but do not import both of them.

Using the Plugin in your App

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

import Segment
import SegmentBraze // <-- Add this line, or replace with `import SegmentBrazeUI` if you need UI components

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

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

Your events will now be given Braze session data and start flowing to Braze.

Additional Configuration

The BrazeDestination initializer accepts two optional parameters allowing you more control over the SDK's behavior. For a full list of available configurations, refer to Braze.Configuration.

BrazeDestination(
  additionalConfiguration: { configuration in
    // Configure the Braze SDK here, e.g.:
    // - Debug / verbose logs
    configuration.logger.level = .debug

    // - Enable automatic push notifications support
    configuration.push.automation = true
    configuration.push.automation.requestAuthorizationAtLaunch = false

    // - Enable universal link forwarding
    configuration.forwardUniversalLinks = true
  },
  additionalSetup: { braze in
    // Post initialization setup here (e.g. setting up delegates, subscriptions, keep a
    // reference to the initialized Braze instance, etc.)
  }
)

Push Notifications Support

To enable push notifications support, refer to the Push Notifications documentation. To keep the integration minimal, the Braze SDK provides push automation features (see sample code above and the automation documentation).

IDFA Collection

When making use of the IDFACollection Segment plugin, the BrazeDestination will automatically forward the collected IDFA to Braze.

Questions?

If you have questions, please contact support@braze.com or open a GitHub Issue.

About

A Segment Swift destination plugin for Braze

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%