Skip to content

Commit cae2997

Browse files
authored
Merge pull request #288 from Iterable/MOB-898-integration-2
[MOB-898] move some constants out of individual files and some minor fixes
2 parents d6449f7 + 5139fcb commit cae2997

7 files changed

+53
-52
lines changed

swift-sdk/Constants.swift

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import Foundation
77

8-
// Iterable API Endpoints
98
enum Endpoint {
109
private static let apiHostName = "https://api.iterable.com"
1110
private static let linksHostName = "https://links.iterable.com"
@@ -302,6 +301,36 @@ extension Array: JsonValueRepresentable where Element: JsonValueRepresentable {
302301
}
303302
}
304303

304+
enum MobileDeviceType: String, Codable {
305+
case iOS
306+
case Android
307+
}
308+
309+
@objc public enum IterableActionSource: Int {
310+
case push
311+
case universalLink
312+
case inApp
313+
}
314+
315+
// Lowest level that will be logged. By default the LogLevel is set to LogLevel.info.
316+
@objc(IterableLogLevel) public enum LogLevel: Int {
317+
case debug = 1
318+
case info
319+
case error
320+
}
321+
322+
/**
323+
Enum representing push platform; apple push notification service, production vs sandbox
324+
*/
325+
@objc public enum PushServicePlatform: Int {
326+
/** The sandbox push service */
327+
case sandbox
328+
/** The production push service */
329+
case production
330+
/** Detect automatically */
331+
case auto
332+
}
333+
305334
// These are custom action for "iterable://delete" etc.
306335
public enum IterableCustomActionName: String, CaseIterable {
307336
case dismiss
@@ -312,3 +341,5 @@ public typealias ITEActionBlock = (String?) -> Void
312341
public typealias ITBURLCallback = (URL?) -> Void
313342
public typealias OnSuccessHandler = (_ data: [AnyHashable: Any]?) -> Void
314343
public typealias OnFailureHandler = (_ reason: String?, _ data: Data?) -> Void
344+
public typealias UrlHandler = (URL) -> Bool
345+
public typealias CustomActionHandler = (String) -> Bool

swift-sdk/Internal/DeviceInfo.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ struct DeviceInfo: Codable {
1010
let mobileDeviceType = MobileDeviceType.iOS
1111
let deviceFp: DeviceFp
1212

13-
enum MobileDeviceType: String, Codable {
14-
case iOS
15-
case Android
16-
}
17-
1813
struct DeviceFp: Codable {
1914
let userInterfaceIdiom: String
2015
let screenWidth: String

swift-sdk/Internal/IterableActionRunner.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import Foundation
77
import UIKit
88

9-
public typealias UrlHandler = (URL) -> Bool
10-
public typealias CustomActionHandler = (String) -> Bool
11-
129
/// handles opening of Urls
1310
@objc public protocol UrlOpenerProtocol: AnyObject {
1411
@objc func open(url: URL)

swift-sdk/IterableAction.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import Foundation
99
`IterableAction` represents an action defined as a response to user events.
1010
It is currently used in push notification actions (open push & action buttons).
1111
*/
12-
@objcMembers public class IterableAction: NSObject {
12+
@objcMembers
13+
public class IterableAction: NSObject {
1314
/** Open the URL or deep link */
1415
public static let actionTypeOpenUrl = "openUrl"
16+
1517
/**
1618
* Action type
1719
*
@@ -21,6 +23,7 @@ import Foundation
2123
* For other types, `IterableCustomActionDelegate` will be called.
2224
*/
2325
public var type: String
26+
2427
/**
2528
* Additional data, its content depends on the action type
2629
*/
@@ -38,11 +41,13 @@ import Foundation
3841
* - parameter dictionary: Dictionary containing action data
3942
* - returns: `IterableAction` instance
4043
*/
41-
@objc(actionFromDictionary:) public static func action(fromDictionary dictionary: [AnyHashable: Any]) -> IterableAction? {
44+
@objc(actionFromDictionary:)
45+
public static func action(fromDictionary dictionary: [AnyHashable: Any]) -> IterableAction? {
4246
return IterableAction(withDictionary: dictionary)
4347
}
4448

45-
@objc(actionOpenUrl:) public static func actionOpenUrl(fromUrlString: String) -> IterableAction? {
49+
@objc(actionOpenUrl:)
50+
public static func actionOpenUrl(fromUrlString: String) -> IterableAction? {
4651
return IterableAction(withDictionary: ["type": IterableAction.actionTypeOpenUrl, "data": fromUrlString])
4752
}
4853

swift-sdk/IterableActionContext.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@
55

66
import Foundation
77

8-
@objc public enum IterableActionSource: Int {
9-
case push
10-
case universalLink
11-
case inApp
12-
}
13-
14-
@objcMembers public class IterableActionContext: NSObject {
8+
@objcMembers
9+
public class IterableActionContext: NSObject {
1510
public let action: IterableAction
1611
public let source: IterableActionSource
1712

swift-sdk/IterableAttributionInfo.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import Foundation
77

88
@objc public class IterableAttributionInfo: NSObject, Codable {
9-
private enum Keys: String {
9+
enum CodingKeys: String, CodingKey {
1010
case campaignId
1111
case templateId
1212
case messageId
@@ -22,12 +22,6 @@ import Foundation
2222
self.messageId = messageId
2323
}
2424

25-
enum CodingKeys: String, CodingKey {
26-
case campaignId
27-
case templateId
28-
case messageId
29-
}
30-
3125
public required init(from decoder: Decoder) throws {
3226
let values = try decoder.container(keyedBy: CodingKeys.self)
3327
campaignId = NSNumber(value: try values.decode(Int.self, forKey: .campaignId))

swift-sdk/IterableConfig.swift

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import Foundation
1515
* - parameter context: Metadata containing the original action and the source: push or universal link.
1616
* - returns: Boolean value. Return true if the URL was handled to override default behavior.
1717
*/
18-
@objc(handleIterableURL:context:) func handle(iterableURL url: URL, inContext context: IterableActionContext) -> Bool
18+
@objc(handleIterableURL:context:)
19+
func handle(iterableURL url: URL, inContext context: IterableActionContext) -> Bool
1920
}
2021

2122
/**
@@ -28,7 +29,8 @@ import Foundation
2829
* - parameter context: Metadata containing the original action and the source: push or universal link.
2930
* - returns: Boolean value. Reserved for future use.
3031
*/
31-
@objc(handleIterableCustomAction:context:) func handle(iterableCustomAction action: IterableAction, inContext context: IterableActionContext) -> Bool
32+
@objc(handleIterableCustomAction:context:)
33+
func handle(iterableCustomAction action: IterableAction, inContext context: IterableActionContext) -> Bool
3234
}
3335

3436
/**
@@ -41,16 +43,8 @@ import Foundation
4143
* - parameter message: `IterableInAppMessage` object containing information regarding in-app to display
4244
* - returns: Return `show` to show the in-app or `skip` to skip this.
4345
*/
44-
@objc(onNewMessage:) func onNew(message: IterableInAppMessage) -> InAppShowResponse
45-
}
46-
47-
/**
48-
* Lowest level that will be logged. By default the LogLevel is set to LogLevel.info.
49-
*/
50-
@objc(IterableLogLevel) public enum LogLevel: Int {
51-
case debug = 1
52-
case info
53-
case error
46+
@objc(onNewMessage:)
47+
func onNew(message: IterableInAppMessage) -> InAppShowResponse
5448
}
5549

5650
/**
@@ -62,25 +56,15 @@ import Foundation
6256
* - parameter level: The log level.
6357
* - parameter message: The message to log. The message will include file, method and line of the call.
6458
*/
65-
@objc(log:Message:) func log(level: LogLevel, message: String)
66-
}
67-
68-
/**
69-
Enum representing push platform; apple push notification service, production vs sandbox
70-
*/
71-
@objc public enum PushServicePlatform: Int {
72-
/** The sandbox push service */
73-
case sandbox
74-
/** The production push service */
75-
case production
76-
/** Detect automatically */
77-
case auto
59+
@objc(log:message:)
60+
func log(level: LogLevel, message: String)
7861
}
7962

8063
/**
8164
Iterable Configuration Object. Use this when initializing the API.
8265
*/
83-
@objcMembers public class IterableConfig: NSObject {
66+
@objcMembers
67+
public class IterableConfig: NSObject {
8468
/**
8569
* You don't have to set this variable. Set this value only if you are an existing Iterable customer who has already setup mobile integrations in Iterable Web UI.
8670
* In that case, set this variable to the push integration name that you have set for 'APNS' in Iterable Web UI.

0 commit comments

Comments
 (0)