Coder Social home page Coder Social logo

braze-segment-swift's Introduction

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.

braze-segment-swift's People

Contributors

michaelghseg avatar jerielng avatar bsneed avatar hokstuff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.