Skip to content

Commit b0dd14a

Browse files
christinasundChristina
and
Christina
authored
2.0.0 (#12)
* 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]>
1 parent 46e865c commit b0dd14a

28 files changed

+2101
-2633
lines changed

Cartfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github "tealium/tealium-swift" ~> 1.9
2-
binary "https://raw.githubusercontent.com/Appboy/appboy-ios-sdk/master/appboy_ios_sdk_core.json" ~> 3.21
1+
github "tealium/tealium-swift" ~> 2.1
2+
binary "https://raw.githubusercontent.com/Appboy/appboy-ios-sdk/master/appboy_ios_sdk_core.json" ~> 3.2

Cartfile.resolved

-3
This file was deleted.

Objective-C/BrazeCommand.swift

-477
This file was deleted.

Objective-C/BrazeTracker.swift

-365
This file was deleted.

Objective-C/DateConverter.swift

-31
This file was deleted.

Sources/BrazeCommand.swift

-450
This file was deleted.

Sources/BrazeConstants.swift

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
//
2+
// BrazeConstants.swift
3+
// TealiumBraze
4+
//
5+
// Created by Christina S on 9/21/20.
6+
// Copyright © 2020 Tealium. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public enum BrazeConstants {
12+
13+
static let commandName = "command_name"
14+
static let separator: Character = ","
15+
static let commandId = "braze"
16+
static let description = "Braze Remote Command"
17+
18+
enum Commands: String {
19+
case initialize = "initialize"
20+
case userIdentifier = "useridentifier"
21+
case userAlias = "useralias"
22+
case userAttribute = "userattribute"
23+
case facebookUser = "facebookuser"
24+
case twitterUser = "twitteruser"
25+
case setCustomAttribute = "setcustomattribute"
26+
case unsetCustomAttribute = "unsetcustomattribute"
27+
case setCustomArrayAttribute = "setcustomarrayattribute"
28+
case appendCustomArrayAttribute = "appendcustomarrayattribute"
29+
case removeCustomArrayAttribute = "removecustomarrayattribute"
30+
case emailNotification = "emailnotification"
31+
case pushNotification = "pushnotification"
32+
case incrementCustomAttribute = "incrementcustomattribute"
33+
case logCustomEvent = "logcustomevent"
34+
case logPurchase = "logpurchase"
35+
case setLastKnownLocation = "setlastknownlocation"
36+
case enableSDK = "enablesdk"
37+
case wipeData = "wipedata"
38+
}
39+
40+
enum Keys {
41+
static let apiKey = "api_key"
42+
static let launchOptions = "launch_options"
43+
static let pushToken = "push_token"
44+
static let userAttribute = "user_attributes"
45+
static let userIdentifier = "user_id"
46+
static let userAlias = "user_alias"
47+
static let aliasLabel = "alias_label"
48+
static let customAttribute = "set_custom_attribute"
49+
static let customArrayAttribute = "set_custom_array_attribute"
50+
static let appendCustomArrayAttribute = "append_custom_array_attribute"
51+
static let removeCustomArrayAttribute = "remove_custom_array_attribute"
52+
static let unsetCustomAttribute = "unset_custom_attribute"
53+
static let incrementCustomAttribute = "increment_custom_attribute"
54+
static let emailNotification = "email_notification"
55+
static let pushNotification = "push_notification"
56+
static let eventKey = "event"
57+
static let eventProperties = "event_properties"
58+
static let eventName = "event_name"
59+
static let productIdentifier = "product_id"
60+
static let currency = "order_currency"
61+
static let price = "product_unit_price"
62+
static let quantity = "quantity"
63+
static let purchaseKey = "purchase"
64+
static let purchaseProperties = "purchase_properties"
65+
static let facebookUser = "facebook_user"
66+
static let twitterUser = "twitter_user"
67+
static let enableSDK = "enable_sdk"
68+
static let sessionTimeout = "session_timeout"
69+
static let disableLocation = "disable_location"
70+
static let enableGeofences = "enable_geofences"
71+
static let triggerIntervalSeconds = "trigger_interval_seconds"
72+
static let latitude = "location_latitude"
73+
static let longitude = "location_longitude"
74+
static let horizontalAccuracy = "location_horizontal_accuracy"
75+
static let altitude = "location_altitude"
76+
static let verticalAccuracy = "location_vertical_accuracy"
77+
static let requestProcessingPolicy = "request_processing_policy"
78+
static let flushInterval = "flush_interval"
79+
static let enableAdvertiserTracking = "enable_advertiser_tracking"
80+
static let enableDeepLinkHandling = "enable_deep_link_handling"
81+
static let customEndpoint = "custom_endpoint"
82+
static let deviceOptions = "device_options"
83+
static let pushStoryIdentifier = "push_story_identifier"
84+
}
85+
86+
enum Options {
87+
static let ABKRequestProcessingPolicyOptionKey = "ABKRequestProcessingPolicyOptionKey"
88+
static let ABKFlushIntervalOptionKey = "ABKFlushIntervalOptionKey"
89+
static let ABKEnableAutomaticLocationCollectionKey = "ABKEnableAutomaticLocationCollectionKey"
90+
static let ABKEnableGeofencesKey = "ABKEnableGeofencesKey"
91+
static let ABKIDFADelegateKey = "ABKIDFADelegateKey"
92+
static let ABKEndpointKey = "ABKEndpointKey"
93+
static let ABKURLDelegateKey = "ABKURLDelegateKey"
94+
static let ABKSessionTimeoutKey = "ABKSessionTimeoutKey"
95+
static let ABKMinimumTriggerTimeIntervalKey = "ABKMinimumTriggerTimeIntervalKey"
96+
static let ABKDeviceWhitelistKey = "ABKDeviceWhitelistKey"
97+
static let ABKPushStoryAppGroupKey = "ABKPushStoryAppGroupKey"
98+
}
99+
100+
enum SocialMedia {
101+
static let userInfo = "user_info"
102+
static let friendsCount = "friends_count"
103+
static let likes = "likes"
104+
static let userDescription = "description"
105+
static let twitterName = "twitter_name"
106+
static let profileImageUrl = "profile_image_url"
107+
static let screenName = "screen_name"
108+
static let followersCount = "followers_count"
109+
static let statusesCount = "statuses_count"
110+
static let twitterId = "twitter_id"
111+
}
112+
113+
}
114+
115+
public enum AppboyUserAttribute: String, CaseIterable {
116+
case firstName = "first_name"
117+
case lastName = "last_name"
118+
case email
119+
case dateOfBirth = "date_of_birth"
120+
case country
121+
case language
122+
case homeCity = "home_city"
123+
case phone
124+
case avatarImageURL = "avatar_image_url"
125+
case gender
126+
}
127+
128+
public enum AppboyUserGenderType: Int {
129+
case male
130+
case female
131+
case other
132+
case unknown
133+
case notApplicable
134+
case preferNotToSay
135+
136+
static func from(_ value: String) -> AppboyUserGenderType {
137+
let lowercasedGender = value.lowercased()
138+
if lowercasedGender == "male" {
139+
return .male
140+
} else if lowercasedGender == "female" {
141+
return .female
142+
} else if lowercasedGender == "other" {
143+
return .other
144+
} else if lowercasedGender == "unknown" {
145+
return .unknown
146+
} else if lowercasedGender == "notapplicable" || lowercasedGender == "not_applicable" {
147+
return .notApplicable
148+
} else {
149+
return .preferNotToSay
150+
}
151+
}
152+
}
153+
154+
public enum AppboyNotificationSubscription: String {
155+
case optedIn
156+
case subscribed
157+
case unsubscribed
158+
159+
static func from(_ value: String) -> AppboyNotificationSubscription? {
160+
let lowercasedSubscription = value.lowercased()
161+
if lowercasedSubscription == "optedin" {
162+
return .optedIn
163+
} else if lowercasedSubscription == "subscribed" {
164+
return .subscribed
165+
} else if lowercasedSubscription == "unsubscribed" {
166+
return .unsubscribed
167+
} else {
168+
return nil
169+
}
170+
}
171+
}

Sources/BrazeTracker.swift Sources/BrazeInstance.swift

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
2-
// BrazeTracker.swift
3-
// RemoteCommandModulesTests
2+
// BrazeInstance.swift
3+
// TealiumBraze
44
//
55
// Created by Jonathan Wong on 11/16/18.
66
// Copyright © 2018 Tealium. All rights reserved.
@@ -20,7 +20,7 @@ import TealiumRemoteCommands
2020
public protocol TealiumApplication { }
2121
extension UIApplication: TealiumApplication { }
2222

23-
public protocol BrazeTrackable {
23+
public protocol BrazeCommand {
2424

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

116-
public class BrazeTracker: BrazeTrackable, BrazeCommandNotifier {
116+
public class BrazeInstance: BrazeCommand, BrazeCommandNotifier {
117117

118118
public init() { }
119119

@@ -233,38 +233,38 @@ public class BrazeTracker: BrazeTrackable, BrazeCommandNotifier {
233233
}
234234

235235
public func setFacebookUser(_ user: [String: Any]) {
236-
guard let userInfo = user[SocialMediaKey.userInfo.rawValue] as? [String: Any],
237-
let friendsCount = user[SocialMediaKey.friendsCount.rawValue] as? Int else {
236+
guard let userInfo = user[BrazeConstants.SocialMedia.userInfo] as? [String: Any],
237+
let friendsCount = user[BrazeConstants.SocialMedia.friendsCount] as? Int else {
238238
return
239239
}
240-
let likes: [Any]? = user[SocialMediaKey.likes.rawValue] as? [Any]
240+
let likes: [Any]? = user[BrazeConstants.SocialMedia.likes] as? [Any]
241241
Appboy.sharedInstance()?.user.facebookUser = ABKFacebookUser(facebookUserDictionary: userInfo, numberOfFriends: friendsCount, likes: likes)
242242
}
243243

244244
public func setTwitterUser(_ user: [String: Any]) {
245245
let twitterUser = ABKTwitterUser()
246-
if let userDescription = user[SocialMediaKey.userDescription.rawValue] as? String {
246+
if let userDescription = user[BrazeConstants.SocialMedia.userDescription] as? String {
247247
twitterUser.userDescription = userDescription
248248
}
249-
if let twitterName = user[SocialMediaKey.twitterName.rawValue] as? String {
249+
if let twitterName = user[BrazeConstants.SocialMedia.twitterName] as? String {
250250
twitterUser.twitterName = twitterName
251251
}
252-
if let profileImageUrl = user[SocialMediaKey.profileImageUrl.rawValue] as? String {
252+
if let profileImageUrl = user[BrazeConstants.SocialMedia.profileImageUrl] as? String {
253253
twitterUser.profileImageUrl = profileImageUrl
254254
}
255-
if let screenName = user[SocialMediaKey.screenName.rawValue] as? String {
255+
if let screenName = user[BrazeConstants.SocialMedia.screenName] as? String {
256256
twitterUser.screenName = screenName
257257
}
258-
if let followersCount = user[SocialMediaKey.followersCount.rawValue] as? Int {
258+
if let followersCount = user[BrazeConstants.SocialMedia.followersCount] as? Int {
259259
twitterUser.followersCount = followersCount
260260
}
261-
if let friendsCount = user[SocialMediaKey.friendsCount.rawValue] as? Int {
261+
if let friendsCount = user[BrazeConstants.SocialMedia.friendsCount] as? Int {
262262
twitterUser.friendsCount = friendsCount
263263
}
264-
if let statusesCount = user[SocialMediaKey.statusesCount.rawValue] as? Int {
264+
if let statusesCount = user[BrazeConstants.SocialMedia.statusesCount] as? Int {
265265
twitterUser.statusesCount = statusesCount
266266
}
267-
if let twitterId = user[SocialMediaKey.twitterId.rawValue] as? Int {
267+
if let twitterId = user[BrazeConstants.SocialMedia.twitterId] as? Int {
268268
twitterUser.twitterID = twitterId
269269
}
270270
Appboy.sharedInstance()?.user.twitterUser = twitterUser

0 commit comments

Comments
 (0)