Skip to content

Commit

Permalink
2.0.0 (#12)
Browse files Browse the repository at this point in the history
* Update to use JSON remote commands

* Remove print statements

* Updated podspec

* Update carthage builds and build settings

* Update Cartfile

* Update profile in TealiumHelper

* Update Tracker to Instance

* JSON remote commands

* Remove Cartfile.resolved

* Update podspec

* Update to weakSelf

Co-authored-by: Christina <[email protected]>
  • Loading branch information
christinasund and Christina authored Oct 21, 2020
1 parent 46e865c commit b0dd14a
Show file tree
Hide file tree
Showing 28 changed files with 2,101 additions and 2,633 deletions.
4 changes: 2 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "tealium/tealium-swift" ~> 1.9
binary "https://raw.githubusercontent.com/Appboy/appboy-ios-sdk/master/appboy_ios_sdk_core.json" ~> 3.21
github "tealium/tealium-swift" ~> 2.1
binary "https://raw.githubusercontent.com/Appboy/appboy-ios-sdk/master/appboy_ios_sdk_core.json" ~> 3.2
3 changes: 0 additions & 3 deletions Cartfile.resolved

This file was deleted.

477 changes: 0 additions & 477 deletions Objective-C/BrazeCommand.swift

This file was deleted.

365 changes: 0 additions & 365 deletions Objective-C/BrazeTracker.swift

This file was deleted.

31 changes: 0 additions & 31 deletions Objective-C/DateConverter.swift

This file was deleted.

450 changes: 0 additions & 450 deletions Sources/BrazeCommand.swift

This file was deleted.

171 changes: 171 additions & 0 deletions Sources/BrazeConstants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
//
// BrazeConstants.swift
// TealiumBraze
//
// Created by Christina S on 9/21/20.
// Copyright © 2020 Tealium. All rights reserved.
//

import Foundation

public enum BrazeConstants {

static let commandName = "command_name"
static let separator: Character = ","
static let commandId = "braze"
static let description = "Braze Remote Command"

enum Commands: String {
case initialize = "initialize"
case userIdentifier = "useridentifier"
case userAlias = "useralias"
case userAttribute = "userattribute"
case facebookUser = "facebookuser"
case twitterUser = "twitteruser"
case setCustomAttribute = "setcustomattribute"
case unsetCustomAttribute = "unsetcustomattribute"
case setCustomArrayAttribute = "setcustomarrayattribute"
case appendCustomArrayAttribute = "appendcustomarrayattribute"
case removeCustomArrayAttribute = "removecustomarrayattribute"
case emailNotification = "emailnotification"
case pushNotification = "pushnotification"
case incrementCustomAttribute = "incrementcustomattribute"
case logCustomEvent = "logcustomevent"
case logPurchase = "logpurchase"
case setLastKnownLocation = "setlastknownlocation"
case enableSDK = "enablesdk"
case wipeData = "wipedata"
}

enum Keys {
static let apiKey = "api_key"
static let launchOptions = "launch_options"
static let pushToken = "push_token"
static let userAttribute = "user_attributes"
static let userIdentifier = "user_id"
static let userAlias = "user_alias"
static let aliasLabel = "alias_label"
static let customAttribute = "set_custom_attribute"
static let customArrayAttribute = "set_custom_array_attribute"
static let appendCustomArrayAttribute = "append_custom_array_attribute"
static let removeCustomArrayAttribute = "remove_custom_array_attribute"
static let unsetCustomAttribute = "unset_custom_attribute"
static let incrementCustomAttribute = "increment_custom_attribute"
static let emailNotification = "email_notification"
static let pushNotification = "push_notification"
static let eventKey = "event"
static let eventProperties = "event_properties"
static let eventName = "event_name"
static let productIdentifier = "product_id"
static let currency = "order_currency"
static let price = "product_unit_price"
static let quantity = "quantity"
static let purchaseKey = "purchase"
static let purchaseProperties = "purchase_properties"
static let facebookUser = "facebook_user"
static let twitterUser = "twitter_user"
static let enableSDK = "enable_sdk"
static let sessionTimeout = "session_timeout"
static let disableLocation = "disable_location"
static let enableGeofences = "enable_geofences"
static let triggerIntervalSeconds = "trigger_interval_seconds"
static let latitude = "location_latitude"
static let longitude = "location_longitude"
static let horizontalAccuracy = "location_horizontal_accuracy"
static let altitude = "location_altitude"
static let verticalAccuracy = "location_vertical_accuracy"
static let requestProcessingPolicy = "request_processing_policy"
static let flushInterval = "flush_interval"
static let enableAdvertiserTracking = "enable_advertiser_tracking"
static let enableDeepLinkHandling = "enable_deep_link_handling"
static let customEndpoint = "custom_endpoint"
static let deviceOptions = "device_options"
static let pushStoryIdentifier = "push_story_identifier"
}

enum Options {
static let ABKRequestProcessingPolicyOptionKey = "ABKRequestProcessingPolicyOptionKey"
static let ABKFlushIntervalOptionKey = "ABKFlushIntervalOptionKey"
static let ABKEnableAutomaticLocationCollectionKey = "ABKEnableAutomaticLocationCollectionKey"
static let ABKEnableGeofencesKey = "ABKEnableGeofencesKey"
static let ABKIDFADelegateKey = "ABKIDFADelegateKey"
static let ABKEndpointKey = "ABKEndpointKey"
static let ABKURLDelegateKey = "ABKURLDelegateKey"
static let ABKSessionTimeoutKey = "ABKSessionTimeoutKey"
static let ABKMinimumTriggerTimeIntervalKey = "ABKMinimumTriggerTimeIntervalKey"
static let ABKDeviceWhitelistKey = "ABKDeviceWhitelistKey"
static let ABKPushStoryAppGroupKey = "ABKPushStoryAppGroupKey"
}

enum SocialMedia {
static let userInfo = "user_info"
static let friendsCount = "friends_count"
static let likes = "likes"
static let userDescription = "description"
static let twitterName = "twitter_name"
static let profileImageUrl = "profile_image_url"
static let screenName = "screen_name"
static let followersCount = "followers_count"
static let statusesCount = "statuses_count"
static let twitterId = "twitter_id"
}

}

public enum AppboyUserAttribute: String, CaseIterable {
case firstName = "first_name"
case lastName = "last_name"
case email
case dateOfBirth = "date_of_birth"
case country
case language
case homeCity = "home_city"
case phone
case avatarImageURL = "avatar_image_url"
case gender
}

public enum AppboyUserGenderType: Int {
case male
case female
case other
case unknown
case notApplicable
case preferNotToSay

static func from(_ value: String) -> AppboyUserGenderType {
let lowercasedGender = value.lowercased()
if lowercasedGender == "male" {
return .male
} else if lowercasedGender == "female" {
return .female
} else if lowercasedGender == "other" {
return .other
} else if lowercasedGender == "unknown" {
return .unknown
} else if lowercasedGender == "notapplicable" || lowercasedGender == "not_applicable" {
return .notApplicable
} else {
return .preferNotToSay
}
}
}

public enum AppboyNotificationSubscription: String {
case optedIn
case subscribed
case unsubscribed

static func from(_ value: String) -> AppboyNotificationSubscription? {
let lowercasedSubscription = value.lowercased()
if lowercasedSubscription == "optedin" {
return .optedIn
} else if lowercasedSubscription == "subscribed" {
return .subscribed
} else if lowercasedSubscription == "unsubscribed" {
return .unsubscribed
} else {
return nil
}
}
}
30 changes: 15 additions & 15 deletions Sources/BrazeTracker.swift → Sources/BrazeInstance.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// BrazeTracker.swift
// RemoteCommandModulesTests
// BrazeInstance.swift
// TealiumBraze
//
// Created by Jonathan Wong on 11/16/18.
// Copyright © 2018 Tealium. All rights reserved.
Expand All @@ -20,7 +20,7 @@ import TealiumRemoteCommands
public protocol TealiumApplication { }
extension UIApplication: TealiumApplication { }

public protocol BrazeTrackable {
public protocol BrazeCommand {

// MARK: Initialization
func initializeBraze(apiKey: String, application: TealiumApplication, launchOptions: [AnyHashable: Any]?)
Expand Down Expand Up @@ -113,7 +113,7 @@ public protocol BrazeCommandNotifier {
func pushAuthorization(fromUserNotificationCenter: Bool)
}

public class BrazeTracker: BrazeTrackable, BrazeCommandNotifier {
public class BrazeInstance: BrazeCommand, BrazeCommandNotifier {

public init() { }

Expand Down Expand Up @@ -233,38 +233,38 @@ public class BrazeTracker: BrazeTrackable, BrazeCommandNotifier {
}

public func setFacebookUser(_ user: [String: Any]) {
guard let userInfo = user[SocialMediaKey.userInfo.rawValue] as? [String: Any],
let friendsCount = user[SocialMediaKey.friendsCount.rawValue] as? Int else {
guard let userInfo = user[BrazeConstants.SocialMedia.userInfo] as? [String: Any],
let friendsCount = user[BrazeConstants.SocialMedia.friendsCount] as? Int else {
return
}
let likes: [Any]? = user[SocialMediaKey.likes.rawValue] as? [Any]
let likes: [Any]? = user[BrazeConstants.SocialMedia.likes] as? [Any]
Appboy.sharedInstance()?.user.facebookUser = ABKFacebookUser(facebookUserDictionary: userInfo, numberOfFriends: friendsCount, likes: likes)
}

public func setTwitterUser(_ user: [String: Any]) {
let twitterUser = ABKTwitterUser()
if let userDescription = user[SocialMediaKey.userDescription.rawValue] as? String {
if let userDescription = user[BrazeConstants.SocialMedia.userDescription] as? String {
twitterUser.userDescription = userDescription
}
if let twitterName = user[SocialMediaKey.twitterName.rawValue] as? String {
if let twitterName = user[BrazeConstants.SocialMedia.twitterName] as? String {
twitterUser.twitterName = twitterName
}
if let profileImageUrl = user[SocialMediaKey.profileImageUrl.rawValue] as? String {
if let profileImageUrl = user[BrazeConstants.SocialMedia.profileImageUrl] as? String {
twitterUser.profileImageUrl = profileImageUrl
}
if let screenName = user[SocialMediaKey.screenName.rawValue] as? String {
if let screenName = user[BrazeConstants.SocialMedia.screenName] as? String {
twitterUser.screenName = screenName
}
if let followersCount = user[SocialMediaKey.followersCount.rawValue] as? Int {
if let followersCount = user[BrazeConstants.SocialMedia.followersCount] as? Int {
twitterUser.followersCount = followersCount
}
if let friendsCount = user[SocialMediaKey.friendsCount.rawValue] as? Int {
if let friendsCount = user[BrazeConstants.SocialMedia.friendsCount] as? Int {
twitterUser.friendsCount = friendsCount
}
if let statusesCount = user[SocialMediaKey.statusesCount.rawValue] as? Int {
if let statusesCount = user[BrazeConstants.SocialMedia.statusesCount] as? Int {
twitterUser.statusesCount = statusesCount
}
if let twitterId = user[SocialMediaKey.twitterId.rawValue] as? Int {
if let twitterId = user[BrazeConstants.SocialMedia.twitterId] as? Int {
twitterUser.twitterID = twitterId
}
Appboy.sharedInstance()?.user.twitterUser = twitterUser
Expand Down
Loading

0 comments on commit b0dd14a

Please sign in to comment.