Skip to content

Commit

Permalink
[MT-883] Add remote command version and update package manager depend…
Browse files Browse the repository at this point in the history
…encies (#14)

* [MT-883] add name and version to BrazeRemoteCommand

Used by new TealiumSwift to track what commands and version are being used.
Fix remote commands interoperability with TealiumSwift 2.5+
Upgrade Braze to 4.0+

* [MT-883] add SwiftPackageManager support

* [MT-883] Fix project for carthage

removed build phase script and manually added the frameworks

* Update carthage to use binary dependency for braze SDK

* Update dependencies for swift 2.6

* SPM versions up to next major

* [MT-883] Add tealium metadata and remove useless initialize method

* Add braze debug logging on sample
  • Loading branch information
Enricoza authored Feb 3, 2022
1 parent b0dd14a commit 357d736
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 104 deletions.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
github "tealium/tealium-swift" ~> 2.1
binary "https://raw.githubusercontent.com/Appboy/appboy-ios-sdk/master/appboy_ios_sdk_core.json" ~> 3.2
github "tealium/tealium-swift" ~> 2.6
binary "https://raw.githubusercontent.com/Appboy/appboy-ios-sdk/master/appboy_ios_sdk.json" ~> 4.4
github "SDWebImage/SDWebImage" ~> 5.12
3 changes: 3 additions & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
binary "https://raw.githubusercontent.com/Appboy/appboy-ios-sdk/master/appboy_ios_sdk.json" "4.4.1"
github "SDWebImage/SDWebImage" "5.12.2"
github "tealium/tealium-swift" "2.5.1"
34 changes: 34 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"object": {
"pins": [
{
"package": "Appboy_iOS_SDK",
"repositoryURL": "https://github.com/Appboy/appboy-ios-sdk",
"state": {
"branch": null,
"revision": "23ec2e8e337856b22801288a0f25ec5895e783a2",
"version": "4.4.1"
}
},
{
"package": "SDWebImage",
"repositoryURL": "https://github.com/SDWebImage/SDWebImage.git",
"state": {
"branch": null,
"revision": "a72df4849408da7e5d3c1b586797b7c601c41d1b",
"version": "5.12.1"
}
},
{
"package": "TealiumSwift",
"repositoryURL": "https://github.com/tealium/tealium-swift",
"state": {
"branch": null,
"revision": "9bd74f09c780862de61101bd147b1c6b232f98ce",
"version": "2.5.1"
}
}
]
},
"version": 1
}
32 changes: 32 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// swift-tools-version:5.1
import PackageDescription

let package = Package(
name: "TealiumBraze",
platforms: [
.iOS(.v10)
],
products: [
.library(name: "TealiumBraze", targets: ["TealiumBraze"])
],
dependencies: [
.package(url: "https://github.com/tealium/tealium-swift", .upToNextMajor(from: "2.6.0")),
.package(url: "https://github.com/Appboy/appboy-ios-sdk", .upToNextMajor(from: "4.4.1"))
],
targets: [
.target(
name: "TealiumBraze",
dependencies: [
.product(name: "AppboyUI", package: "appboy-ios-sdk"),
.product(name: "TealiumCore", package: "tealium-swift"),
.product(name: "TealiumRemoteCommands", package: "tealium-swift")
],
path: "./Sources"),
.testTarget(
name: "TealiumBrazeTests",
dependencies: [
.target(name: "TealiumBraze")
],
path: "./Tests")
]
)
1 change: 1 addition & 0 deletions Sources/BrazeConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum BrazeConstants {
static let separator: Character = ","
static let commandId = "braze"
static let description = "Braze Remote Command"
static let version = "2.1.0"

enum Commands: String {
case initialize = "initialize"
Expand Down
18 changes: 8 additions & 10 deletions Sources/BrazeInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
//

import Foundation
import Appboy_iOS_SDK

#if SWIFT_PACKAGE
import AppboyUI
#else
import Appboy_iOS_SDK
#endif

#if COCOAPODS
import TealiumSwift
#else
import TealiumCore
import TealiumTagManagement
import TealiumRemoteCommands
#endif

Expand All @@ -23,8 +28,6 @@ extension UIApplication: TealiumApplication { }
public protocol BrazeCommand {

// MARK: Initialization
func initializeBraze(apiKey: String, application: TealiumApplication, launchOptions: [AnyHashable: Any]?)

func initializeBraze(apiKey: String, application: TealiumApplication, launchOptions: [AnyHashable: Any]?, appboyOptions: [AnyHashable: Any]?)

// MARK: Geofences
Expand Down Expand Up @@ -117,15 +120,10 @@ public class BrazeInstance: BrazeCommand, BrazeCommandNotifier {

public init() { }

public func initializeBraze(apiKey: String, application: TealiumApplication, launchOptions: [AnyHashable: Any]?) {
DispatchQueue.main.async {
Appboy.start(withApiKey: apiKey, in: application as? UIApplication ?? UIApplication.shared, withLaunchOptions: launchOptions)
}
}

public func initializeBraze(apiKey: String, application: TealiumApplication, launchOptions: [AnyHashable: Any]?, appboyOptions: [AnyHashable: Any]?) {
DispatchQueue.main.async {
Appboy.start(withApiKey: apiKey, in: application as? UIApplication ?? UIApplication.shared, withLaunchOptions: launchOptions, withAppboyOptions: appboyOptions)
Appboy.sharedInstance()?.addSdkMetadata([.tealium])
}
}

Expand Down
16 changes: 11 additions & 5 deletions Sources/BrazeRemoteCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@
//

import UIKit
import Appboy_iOS_SDK

#if SWIFT_PACKAGE
import AppboyUI
#else
import Appboy_iOS_SDK
#endif

#if COCOAPODS
import TealiumSwift
#else
import TealiumCore
import TealiumTagManagement
import TealiumRemoteCommands
#endif

public class BrazeRemoteCommand: RemoteCommand {

override public var version: String? {
return BrazeConstants.version
}
let brazeInstance: BrazeCommand?

public init(brazeInstance: BrazeCommand = BrazeInstance(), type: RemoteCommandType = .webview) {
Expand Down Expand Up @@ -93,9 +101,7 @@ public class BrazeRemoteCommand: RemoteCommand {
if let pushStoryIdentifier = payload[BrazeConstants.Keys.pushStoryIdentifier] as? String {
appboyOptions[BrazeConstants.Options.ABKPushStoryAppGroupKey] = pushStoryIdentifier
}
guard let launchOptions = payload[BrazeConstants.Keys.launchOptions] as? [UIApplication.LaunchOptionsKey: Any] else {
return brazeInstance.initializeBraze(apiKey: apiKey, application: UIApplication.shared, launchOptions: nil, appboyOptions: appboyOptions)
}
let launchOptions = payload[BrazeConstants.Keys.launchOptions] as? [UIApplication.LaunchOptionsKey: Any]
brazeInstance.initializeBraze(apiKey: apiKey, application: UIApplication.shared, launchOptions: launchOptions, appboyOptions: appboyOptions)
case .userIdentifier:
guard let userIdentifier = payload[BrazeConstants.Keys.userIdentifier] as? String else {
Expand Down
14 changes: 7 additions & 7 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 = "2.0.0"
s.version = "2.1.0"
s.summary = "Tealium Swift and Braze integration"
s.description = <<-DESC
Tealium's integration with Braze for iOS.
Expand All @@ -21,8 +21,8 @@ Pod::Spec.new do |s|

# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
s.swift_version = "5.0"
s.platform = :ios, "10.0"
s.ios.deployment_target = "10.0"
s.platform = :ios, "11.0"
s.ios.deployment_target = "11.0"

# ――― Excluded Archs ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
Expand All @@ -35,9 +35,9 @@ Pod::Spec.new do |s|
s.ios.source_files = "Sources/*.{swift}"

# ――― Dependencies ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
s.ios.dependency 'tealium-swift/Core', '~> 2.1'
s.ios.dependency 'tealium-swift/RemoteCommands', '~> 2.1'
s.ios.dependency 'tealium-swift/TagManagement', '~> 2.1'
s.ios.dependency 'Appboy-iOS-SDK', '~> 3.2'
s.ios.dependency 'tealium-swift/Core', '~> 2.6'
s.ios.dependency 'tealium-swift/RemoteCommands', '~> 2.6'
s.ios.dependency 'tealium-swift/TagManagement', '~> 2.6'
s.ios.dependency 'Appboy-iOS-SDK', '~> 4.4'

end
Loading

0 comments on commit 357d736

Please sign in to comment.