Skip to content

Commit

Permalink
[MT-1346] Update Braze SDK to 7.2.0 (#16)
Browse files Browse the repository at this point in the history
* Update braze dependency to 7.2.0

Removed deprecated keys
Changed deprecated methods
Added new configuration options
Removed Twitter/Facebook references in the sample

* Test new config and nested objects in setCustomAttribute from the example

* Removed API key from the remote command config

* Update podspec version and braze carthage map
  • Loading branch information
Enricoza authored Nov 23, 2023
1 parent 3065051 commit cdf678d
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 104 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "tealium/tealium-swift" ~> 2.8
binary "https://raw.githubusercontent.com/Tealium/tealium-ios-braze-remote-command/main/braze.json" ~> 5.8
binary "https://raw.githubusercontent.com/Tealium/tealium-ios-braze-remote-command/main/braze.json" ~> 7.2
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/tealium/tealium-swift", .upToNextMajor(from: "2.8.0")),
.package(url: "https://github.com/braze-inc/braze-swift-sdk", .upToNextMajor(from: "5.6.2"))
.package(url: "https://github.com/braze-inc/braze-swift-sdk", .upToNextMajor(from: "7.2.0"))
],
targets: [
.target(
Expand Down
4 changes: 3 additions & 1 deletion Sources/BrazeConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum BrazeConstants {
static let separator: Character = ","
static let commandId = "braze"
static let description = "Braze Remote Command"
static let version = "3.0.0"
static let version = "3.1.0"

enum Commands: String {
case initialize = "initialize"
Expand Down Expand Up @@ -86,6 +86,8 @@ public enum BrazeConstants {
static let deviceOptions = "device_options"
static let pushStoryIdentifier = "push_story_identifier"
static let subscriptionGroupId = "subscription_group_id"
static let forwardUniversalLinks = "forward_universal_links"
static let useUUIDAsDeviceId = "use_uuid_as_device_id"
}
}

Expand Down
2 changes: 0 additions & 2 deletions Sources/BrazeExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ extension Braze.Configuration.DeviceProperty {
return .pushEnabled
case "pushauthstatus":
return .pushAuthStatus
case "pushdisplayoptions":
return .pushDisplayOptions
default:
return Self(rawValue: value)
}
Expand Down
12 changes: 9 additions & 3 deletions Sources/BrazeInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ public class BrazeInstance: BrazeCommand {
braze.user.setCustomAttribute(key: key, value: value)
} else if let value = value as? Date {
braze.user.setCustomAttribute(key: key, value: value)
} else if let value = value as? [String] {
braze.user.setCustomAttribute(key: key, array: value)
} else if let value = value as? [String: Any] {
braze.user.setCustomAttribute(key: key, dictionary: value)
} else if let value = value as? [[String: Any]] {
braze.user.setCustomAttribute(key: key, array: value)
}
}

Expand All @@ -223,19 +229,19 @@ public class BrazeInstance: BrazeCommand {

public func setCustomAttributeArrayWithKey(_ key: String, array: [String]?) {
onReady { braze in
braze.user.setCustomAttributeArray(key: key, array: array)
braze.user.setCustomAttribute(key: key, array: array)
}
}

public func addToCustomAttributeArrayWithKey(_ key: String, value: String) {
onReady { braze in
braze.user.addToCustomAttributeArray(key: key, value: value)
braze.user.addToCustomAttributeStringArray(key: key, value: value)
}
}

public func removeFromCustomAttributeArrayWithKey(_ key: String, value: String) {
onReady { braze in
braze.user.removeFromCustomAttributeArray(key: key, value: value)
braze.user.removeFromCustomAttributeStringArray(key: key, value: value)
}
}

Expand Down
6 changes: 6 additions & 0 deletions Sources/BrazeRemoteCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ public class BrazeRemoteCommand: RemoteCommand {
brazeConfig.push.appGroup = pushStoryIdentifier
}
brazeConfig.api.sdkFlavor = .tealium
if let useUUIDAsDeviceId = payload[BrazeConstants.Keys.useUUIDAsDeviceId] as? NSNumber {
brazeConfig.useUUIDAsDeviceId = useUUIDAsDeviceId.boolValue
}
if let forwardUniversalLinks = payload[BrazeConstants.Keys.forwardUniversalLinks] as? NSNumber {
brazeConfig.forwardUniversalLinks = forwardUniversalLinks.boolValue
}
return brazeConfig
}
}
4 changes: 2 additions & 2 deletions TealiumBraze.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Pod::Spec.new do |s|
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
s.name = "TealiumBraze"
s.module_name = "TealiumBraze"
s.version = "3.0.0"
s.version = "3.1.0"
s.summary = "Tealium Swift and Braze integration"
s.description = <<-DESC
Tealium's integration with Braze for iOS.
Expand Down Expand Up @@ -33,7 +33,7 @@ Pod::Spec.new do |s|
# ――― Dependencies ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
s.ios.dependency 'tealium-swift/Core', '~> 2.8'
s.ios.dependency 'tealium-swift/RemoteCommands', '~> 2.8'
s.ios.dependency 'BrazeKit', '~> 5.8'
s.ios.dependency 'BrazeKit', '~> 7.2'
s.static_framework = true

end
26 changes: 13 additions & 13 deletions TealiumBrazeExample/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PODS:
- BrazeKit (5.8.1)
- BrazeLocation (5.8.1):
- BrazeKit (= 5.8.1)
- tealium-swift/Core (2.8.2)
- tealium-swift/Lifecycle (2.8.2):
- BrazeKit (7.2.0)
- BrazeLocation (7.2.0):
- BrazeKit (= 7.2.0)
- tealium-swift/Core (2.10.1)
- tealium-swift/Lifecycle (2.10.1):
- tealium-swift/Core
- tealium-swift/RemoteCommands (2.8.2):
- tealium-swift/RemoteCommands (2.10.1):
- tealium-swift/Core
- tealium-swift/TagManagement (2.8.2):
- tealium-swift/TagManagement (2.10.1):
- tealium-swift/Core
- TealiumBraze (3.0.0):
- BrazeKit (~> 5.8.1)
- BrazeKit (~> 7.2)
- tealium-swift/Core (~> 2.8)
- tealium-swift/RemoteCommands (~> 2.8)

Expand All @@ -31,11 +31,11 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
BrazeKit: 312c40ffce4edfef079f3142fe1dfc54b6a65ca5
BrazeLocation: b95623677a4b020e8e48edc120480996d09561e9
tealium-swift: aa249f29ee10924c1cb373c5313e91a99276bfe6
TealiumBraze: 217e7d78da1a301de32cdeb569bee194621255fd
BrazeKit: 3c77dfdf4e96e4ad8636523415e93669b89e26e0
BrazeLocation: 188b5a4210cdac88b5f19f455a1317ed7b809040
tealium-swift: 9ec83baf5419d0bb1e95b184288231e27385015b
TealiumBraze: ff3cadbc6f8351a40467c63a32b97ea93438c479

PODFILE CHECKSUM: 882a9d422c74901cbba8507cb6a543b4c7999cb4

COCOAPODS: 1.11.2
COCOAPODS: 1.14.2
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
import UIKit

class EngagementViewController: UIViewController {

@IBOutlet weak var twitterIdTextField: UITextField!
@IBOutlet weak var twitterNameTextField: UITextField!
@IBOutlet weak var facebookUserTextField: UITextField!
@IBOutlet weak var facebookFriendsTextField: UITextField!
@IBOutlet weak var emailSegmentedControl: UISegmentedControl!
@IBOutlet weak var pushSegmentedControl: UISegmentedControl!

Expand All @@ -27,40 +22,10 @@ class EngagementViewController: UIViewController {
@IBAction func onSend(_ sender: Any) {
var data = [String: Any]()

var facebookInfo = [String: Any]()
facebookInfo["user_info"] = ["username": facebookUserTextField.text]
if let friendsCount = facebookFriendsTextField.text, let count = Int(friendsCount) {
data["facebook_friends_count"] = count
}
data["facebook_user"] = facebookInfo

data["username"] = facebookUserTextField.text ?? ""
data["twitter_id"] = twitterIdTextField.text ?? ""
data["twitter_user_description"] = "awesome engineer"
data["twitter_name"] = twitterNameTextField.text ?? ""
data["list_of_likes"] = [
[
"name": "Bill the Cat",
"id": "155111347875779",
"created_time": "2017-06-18T18:21:04+0000"
],
[
"name": "Calvin and Hobbes",
"id": "257573197608192",
"created_time": "2017-06-18T18:21:02+0000"
],
[
"name": "Berkeley Breathed's Bloom County",
"id": "108793262484769",
"created_time": "2017-06-18T18:20:58+0000"
]
]
data["email_subscription"] = emailSubscription()
data["push_subscription"] = pushSubscription()

TealiumHelper.trackEvent(title: "setengagement", data: data)
TealiumHelper.trackEvent(title: "facebook", data: data)
TealiumHelper.trackEvent(title: "twitter", data: data)
}

private func emailSubscription() -> String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ class EventViewController: UIViewController {
}

@IBAction func setCustomAttributes(_ sender: UIButton) {
let customAttributes: [String: Any] = ["pet": "cat",
"pet_count": 3]
let customAttributes: [String: Any] = [
"pet": "cat",
"pet_count": 3,
"pet_array": ["one", "two", "three"],
"pet_dictionary": ["key": "value", "anotherKey": "anotherValue"],
"pet_objects": [["key1": "value1", "anotherKey1": "anotherValue1"],
["key2": "value2", "anotherKey2": "anotherValue2"]]
]
TealiumHelper.trackEvent(title: "custom_attribute", data: customAttributes)

let customArrayAttributes: [String: Any] = ["pet_names": ["Rosia", "Elsa", "Kawai"]]
Expand Down
39 changes: 5 additions & 34 deletions TealiumBrazeExample/TealiumBrazeExample/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="3X4-F0-9RA">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="3X4-F0-9RA">
<device id="retina6_5" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -150,35 +150,10 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="62" translatesAutoresizingMaskIntoConstraints="NO" id="Ews-YP-hj8">
<rect key="frame" x="16" y="94" width="382" height="316"/>
<rect key="frame" x="16" y="94" width="382" height="124"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="HJX-RT-kkA">
<rect key="frame" x="0.0" y="0.0" width="382" height="34"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Twitter Id" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="I6r-MF-oXf">
<rect key="frame" x="0.0" y="0.0" width="382" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="113" translatesAutoresizingMaskIntoConstraints="NO" id="EmC-pD-AnB">
<rect key="frame" x="0.0" y="96" width="382" height="34"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Facebook User" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="4ko-2G-zfK">
<rect key="frame" x="0.0" y="0.0" width="134.66666666666666" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Num Friends" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Gm2-mo-Hop">
<rect key="frame" x="247.66666666666669" y="0.0" width="134.33333333333331" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" spacing="69" translatesAutoresizingMaskIntoConstraints="NO" id="iob-nN-9FR">
<rect key="frame" x="0.0" y="192" width="382" height="31"/>
<rect key="frame" x="0.0" y="0.0" width="382" height="31"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" text="Email" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5o9-Zy-fkY">
<rect key="frame" x="0.0" y="0.0" width="40.666666666666664" height="31"/>
Expand All @@ -197,7 +172,7 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" alignment="top" spacing="71" translatesAutoresizingMaskIntoConstraints="NO" id="4KP-kk-fNs">
<rect key="frame" x="0.0" y="285" width="382" height="31"/>
<rect key="frame" x="0.0" y="93" width="382" height="31"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" text="Push" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="chp-9h-2nu">
<rect key="frame" x="0.0" y="0.0" width="38" height="20.333333333333332"/>
Expand Down Expand Up @@ -240,11 +215,7 @@
<tabBarItem key="tabBarItem" title="Engagement" id="fGo-64-4WP"/>
<connections>
<outlet property="emailSegmentedControl" destination="Klg-Cv-aS7" id="m3k-hh-d4S"/>
<outlet property="facebookFriendsTextField" destination="Gm2-mo-Hop" id="FKA-xR-5eA"/>
<outlet property="facebookUserTextField" destination="4ko-2G-zfK" id="HeX-lF-2Qi"/>
<outlet property="pushSegmentedControl" destination="gQw-QJ-7es" id="Mgf-yu-aMs"/>
<outlet property="twitterIdTextField" destination="I6r-MF-oXf" id="4is-su-nh0"/>
<outlet property="twitterNameTextField" destination="I6r-MF-oXf" id="4uj-jv-OgO"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="wpC-1e-gdt" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
17 changes: 7 additions & 10 deletions TealiumBrazeExample/TealiumBrazeExample/braze.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"config": {
"api_key": "d0e3ed67-b354-4160-bd38-f5e0be649bcc",
"api_key": "paste_your_api_key_here",
"custom_endpoint": "sdk.iad-01.braze.com",
"session_timeout": 30,
"disable_location": false,
"trigger_interval_seconds": 100
"trigger_interval_seconds": 100,
"use_uuid_as_device_id": true,
"forward_universal_links": true
},
"mappings": {
"customer_id": "user_id",
Expand All @@ -19,19 +21,16 @@
"customer_alias_label": "alias_label",
"pet": "set_custom_attribute.pet",
"pet_count": "set_custom_attribute.pet_count",
"pet_objects": "set_custom_attribute.pet_objects",
"pet_dictionary": "set_custom_attribute.pet_dictionary",
"pet_array": "set_custom_attribute.pet_array",
"pet_count_unset": "unset_custom_attribute",
"pet_count_increment": "increment_custom_attribute.pet_count",
"pet_names": "set_custom_array_attribute.pet_names",
"pet_names_append": "append_custom_array_attribute.pet_names",
"pet_names_remove": "remove_custom_array_attribute.pet_names",
"facebook_user": "facebook_user",
"number_of_friends": "friends_count",
"list_of_likes": "likes",
"facebook_user_properties": "facebook_user",
"social_media_user_description": "description",
"twitter_id": "twitter_id",
"twitter_name": "twitter_name",
"twitter_user_description": "description",
"profile_image_url": "profile_image_url",
"screen_name": "screen_name",
"number_of_followers": "followers_count",
Expand All @@ -55,8 +54,6 @@
},
"commands": {
"launch": "initialize",
"twitter": "twitteruser",
"facebook": "facebookuser",
"setengagement": "emailnotification,pushnotification",
"set_location": "setlastknownlocation",
"custom_attribute": "setcustomattribute",
Expand Down
1 change: 1 addition & 0 deletions braze.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"7.2.0":"https://github.com/braze-inc/braze-swift-sdk/releases/download/7.2.0/BrazeKit.zip",
"5.8.1":"https://github.com/braze-inc/braze-swift-sdk/releases/download/5.8.1/BrazeKit.zip",
"5.8.0":"https://github.com/braze-inc/braze-swift-sdk/releases/download/5.8.0/BrazeKit.zip",
"5.7.0":"https://github.com/braze-inc/braze-swift-sdk/releases/download/5.7.0/BrazeKit.zip",
Expand Down

0 comments on commit cdf678d

Please sign in to comment.