Swiftpack.co - braze-inc/braze-segment-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by braze-inc.
braze-inc/braze-segment-swift 2.0.0
A Segment Swift destination plugin for Braze
⭐️ 1
🕓 2 weeks ago
iOS tvOS
.package(url: "https://github.com/braze-inc/braze-segment-swift.git", from: "2.0.0")

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 [email protected] or open a GitHub Issue.

GitHub

link
Stars: 1
Last commit: 4 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

2.0.0
2 weeks ago

Added

  • Renames this repository from analytics-swift-braze to braze-segment-swift.
  • Adds the SegmentBrazeUI module, which provides the BrazeDestination plugin with BrazeUI support.
    • Use the SegmentBraze module if you do not need any Braze-provided UI.
  • Adds two optional parameters to the BrazeDestination initializer:
    • additionalConfiguration: When provided, this closure is called with the Braze configuration object before the SDK initialization. You can use this to set additional Braze configuration options (e.g. session timeout, push notification automation, etc.).
    • additionalSetup: When provided, this closure is called with the fully initialized Braze instance. You can use this to further customize your usage of the Braze SDK (e.g. register UI delegates, set up messaging subscriptions, etc.)
    • See the updated Sample App for an example of how to use these new parameters.
  • Adds support for automatically forwarding the advertisingIdentifier (IDFA) to Braze when making use of the IDFACollection Segment plugin.
  • Adds support to parse braze_subscription_groups in the Identity traits to subscribe and unsubscribe from Braze subscription groups.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics