Skip to content

Commit 09a5fde

Browse files
committed
Fancify comments and signatures
1 parent 1e0b7a9 commit 09a5fde

9 files changed

+80
-48
lines changed

swift-sdk/Internal/InAppDisplayer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ class InAppDisplayer: InAppDisplayerProtocol {
3030
}
3131

3232
/**
33-
Creates and shows a HTML InApp Notification with trackParameters, backgroundColor with callback handler
33+
Creates and shows a HTML In-app Notification with trackParameters, backgroundColor with callback handler
3434

3535
- parameters:
36-
- htmlString: The NSString containing the dialog HTML
36+
- htmlString: The string containing the dialog HTML
3737
- messageMetadata: Message metadata object.
3838
- backgroundAlpha: The background alpha behind the notification
3939
- padding: The padding around the notification

swift-sdk/Internal/InAppHelper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Ported to Swift by Tapash Majumder on 6/7/18.
44
// Copyright © 2018 Iterable. All rights reserved.
55
//
6-
// Utility Methods for inApp
6+
// Utility Methods for in-app
77
// All classes/structs are internal.
88

99
import UIKit

swift-sdk/Internal/InAppManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
277277
showMessage(fromMessagesProcessorResult: messagesProcessorResult)
278278
}
279279

280-
// This must be called from MainThread
280+
// This must be called from Main Thread
281281
private func showInternal(message: IterableInAppMessage,
282282
consume: Bool,
283283
callback: ITBURLCallback? = nil) {
@@ -307,7 +307,7 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
307307
// set the dismiss time
308308
self.lastDismissedTime = self.dateProvider.currentDate
309309

310-
// check if we need to process more inApps
310+
// check if we need to process more in-apps
311311
self.scheduleNextInAppMessage()
312312

313313
if consume {

swift-sdk/Internal/InAppMessageParser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct InAppMessageParser {
2020
}
2121
}
2222

23-
/// Returns an array of Dictionaries holding inApp messages.
23+
/// Returns an array of Dictionaries holding in-app messages.
2424
private static func getInAppDicts(fromPayload payload: [AnyHashable: Any]) -> [[AnyHashable: Any]] {
2525
return payload[JsonKey.InApp.inAppMessages] as? [[AnyHashable: Any]] ?? []
2626
}
@@ -100,7 +100,7 @@ struct InAppMessageParser {
100100
if let theCampaignId = json[JsonKey.campaignId.jsonKey] as? String {
101101
campaignId = theCampaignId
102102
} else {
103-
ITBDebug("Could not find campaignId") // This is debug level because this happens a lot with proof inApps
103+
ITBDebug("Could not find campaignId") // This is debug level because this happens a lot with proof in-apps
104104
campaignId = ""
105105
}
106106

swift-sdk/Internal/IterableAppIntegrationInternal.swift

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import UserNotifications
1010
// Returns whether notifications are enabled
1111
protocol NotificationStateProviderProtocol {
1212
var notificationsEnabled: Promise<Bool, Error> { get }
13+
1314
func registerForRemoteNotifications()
1415
}
1516

@@ -47,7 +48,9 @@ struct SystemNotificationStateProvider: NotificationStateProviderProtocol {
4748
@available(iOS 10.0, *)
4849
public protocol NotificationResponseProtocol {
4950
var userInfo: [AnyHashable: Any] { get }
51+
5052
var actionIdentifier: String { get }
53+
5154
var textInputResponse: UNTextInputNotificationResponse? { get }
5255
}
5356

@@ -72,11 +75,22 @@ struct UserNotificationResponse: NotificationResponseProtocol {
7275
}
7376
}
7477

75-
/// Abstraction of PushTacking
78+
/// Abstraction of push tracking
7679
public protocol PushTrackerProtocol: AnyObject {
7780
var lastPushPayload: [AnyHashable: Any]? { get }
78-
func trackPushOpen(_ userInfo: [AnyHashable: Any], dataFields: [AnyHashable: Any]?, onSuccess: OnSuccessHandler?, onFailure: OnFailureHandler?)
79-
func trackPushOpen(_ campaignId: NSNumber, templateId: NSNumber?, messageId: String?, appAlreadyRunning: Bool, dataFields: [AnyHashable: Any]?, onSuccess: OnSuccessHandler?, onFailure: OnFailureHandler?)
81+
82+
func trackPushOpen(_ userInfo: [AnyHashable: Any],
83+
dataFields: [AnyHashable: Any]?,
84+
onSuccess: OnSuccessHandler?,
85+
onFailure: OnFailureHandler?)
86+
87+
func trackPushOpen(_ campaignId: NSNumber,
88+
templateId: NSNumber?,
89+
messageId: String?,
90+
appAlreadyRunning: Bool,
91+
dataFields: [AnyHashable: Any]?,
92+
onSuccess: OnSuccessHandler?,
93+
onFailure: OnFailureHandler?)
8094
}
8195

8296
extension PushTrackerProtocol {
@@ -140,6 +154,7 @@ struct IterableAppIntegrationInternal {
140154
*/
141155
func application(_ application: ApplicationStateProviderProtocol, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: ((UIBackgroundFetchResult) -> Void)?) {
142156
ITBInfo()
157+
143158
if case let NotificationInfo.silentPush(silentPush) = NotificationHelper.inspect(notification: userInfo) {
144159
switch silentPush.notificationType {
145160
case .update:
@@ -184,12 +199,15 @@ struct IterableAppIntegrationInternal {
184199
@available(iOS 10.0, *)
185200
func userNotificationCenter(_: UNUserNotificationCenter?, didReceive response: NotificationResponseProtocol, withCompletionHandler completionHandler: (() -> Void)?) {
186201
ITBInfo()
202+
187203
let userInfo = response.userInfo
204+
188205
// Ignore the notification if we've already processed it from launchOptions while initializing SDK
189206
guard !alreadyTracked(userInfo: userInfo) else {
190207
completionHandler?()
191208
return
192209
}
210+
193211
guard let itbl = IterableAppIntegrationInternal.itblValue(fromUserInfo: userInfo) else {
194212
completionHandler?()
195213
return
@@ -217,7 +235,10 @@ struct IterableAppIntegrationInternal {
217235
}
218236

219237
@available(iOS 10.0, *)
220-
private static func createIterableAction(actionIdentifier: String, userText: String?, userInfo: [AnyHashable: Any], iterableElement itbl: [AnyHashable: Any]) -> IterableAction? {
238+
private static func createIterableAction(actionIdentifier: String,
239+
userText: String?,
240+
userInfo: [AnyHashable: Any],
241+
iterableElement itbl: [AnyHashable: Any]) -> IterableAction? {
221242
var action: IterableAction?
222243

223244
if actionIdentifier == UNNotificationDefaultActionIdentifier {

swift-sdk/IterableAPI.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ import UIKit
360360
/**
361361
Tracks a custom event.
362362

363-
- remark: Pass in the the custom event data.
363+
- remark: Pass in the custom event data.
364364

365365
- parameter eventName: Name of the event
366366
*/
@@ -372,7 +372,7 @@ import UIKit
372372
/**
373373
Tracks a custom event.
374374

375-
- remark: Pass in the the custom event data.
375+
- remark: Pass in the custom event data.
376376

377377
- parameter eventName: Name of the event
378378
- parameter dataFields: A `Dictionary` containing any additional information to save along with the event
@@ -385,7 +385,7 @@ import UIKit
385385
/**
386386
Tracks a custom event.
387387

388-
- remark: Pass in the the custom event data.
388+
- remark: Pass in the custom event data.
389389
- parameters:
390390
- eventName: Name of the event
391391
- dataFields: A `Dictionary` containing any additional information to save along with the event
@@ -431,7 +431,7 @@ import UIKit
431431
// MARK: In-App Notifications
432432

433433
/**
434-
Tracks an InAppOpen event.
434+
Tracks an `InAppOpen` event.
435435
- parameter messageId: The messageId of the notification
436436
*/
437437

@@ -443,7 +443,7 @@ import UIKit
443443
}
444444

445445
/**
446-
Tracks an InAppOpen event.
446+
Tracks an `InAppOpen` event.
447447
Usually you don't need to call this method explicitly. IterableSDK will call this automatically.
448448
Call this method only if you are using a custom view controller to render IterableInAppMessages.
449449

@@ -456,7 +456,7 @@ import UIKit
456456
}
457457

458458
/**
459-
Tracks an InAppClick event
459+
Tracks an `InAppClick` event
460460

461461
- parameter messageId: The messageId of the notification
462462
- parameter buttonURL: The url of the button that was clicked
@@ -470,7 +470,7 @@ import UIKit
470470
}
471471

472472
/**
473-
Tracks an InAppClick event.
473+
Tracks an `InAppClick` event.
474474
Usually you don't need to call this method explicitly. IterableSDK will call this automatically.
475475
Call this method only if you are using a custom view controller to render IterableInAppMessages.
476476

@@ -484,7 +484,7 @@ import UIKit
484484
}
485485

486486
/**
487-
Tracks an InAppClose event
487+
Tracks an `InAppClose` event
488488
- parameter message: The in-app message
489489
- parameter clickedUrl: The url that was clicked to close the in-app. It will be `nil` when message is closed on clicking `back`.
490490
*/
@@ -494,7 +494,7 @@ import UIKit
494494
}
495495

496496
/**
497-
Tracks an InAppClose event
497+
Tracks an `InAppClose` event
498498
- parameter message: The in-app message
499499
- parameter location: The location from where this message was shown. `inbox` or `inApp`.
500500
- parameter clickedUrl: The url that was clicked to close the in-app. It will be `nil` when message is closed on clicking `back`.
@@ -505,7 +505,7 @@ import UIKit
505505
}
506506

507507
/**
508-
Tracks an InAppClose event
508+
Tracks an `InAppClose` event
509509
- parameter message: The in-app message
510510
- parameter location: The location from where this message was shown. `inbox` or `inApp`.
511511
- parameter source: Source is `back` if back button was clicked to dismiss in-app message. Otherwise source is `link`.
@@ -517,7 +517,7 @@ import UIKit
517517
}
518518

519519
/**
520-
Consumes the notification and removes it from the list of inAppMessages
520+
Consumes the notification and removes it from the list of in-app messages
521521

522522
- parameter messageId: The messageId of the notification
523523
*/
@@ -530,7 +530,7 @@ import UIKit
530530
}
531531

532532
/**
533-
Consumes the notification and removes it from the list of inAppMessages
533+
Consumes the notification and removes it from the list of in-app messages
534534

535535
- parameter message: The Iterable message that is being consumed
536536
- parameter location: The location from where this message was shown. `inbox` or `inApp`.
@@ -541,7 +541,7 @@ import UIKit
541541
}
542542

543543
/**
544-
Consumes the notification and removes it from the list of inAppMessages
544+
Consumes the notification and removes it from the list of in-app messages
545545

546546
- parameter message: The Iterable message that is being consumed
547547
- parameter location: The location from where this message was shown. `inbox` or `inApp`.
@@ -618,17 +618,17 @@ import UIKit
618618
return internalImplementation?.handleUniversalLink(url) ?? false
619619
}
620620

621-
/// Use this property for getting and showing inApp Messages.
621+
/// Use this property for getting and showing in-app messages.
622622
/// This property has no meaning if IterableAPI has not been initialized using
623623
/// IterableAPI.initialize
624624
/// ```
625625
/// - IterableAPI.inAppManager.getMessages()
626-
/// - IterableAPI.inappManager.show(message: message, consume: true)
626+
/// - IterableAPI.inAppManager.show(message: message, consume: true)
627627
/// ```
628628
public static var inAppManager: IterableInAppManagerProtocol {
629629
guard let internalImplementation = internalImplementation else {
630-
ITBError("IterableAPI is not initialized yet. InApp will not work now.")
631-
assertionFailure("IterableAPI is not initialized yet. In-app will not work now.")
630+
ITBError("IterableAPI is not initialized yet. In-apps will not work now.")
631+
assertionFailure("IterableAPI is not initialized yet. In-apps will not work now.")
632632
return EmptyInAppManager()
633633
}
634634

swift-sdk/IterableAppIntegration.swift

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ import UserNotifications
1818
* - parameter completionHandler: Completion handler passed from the original call. Iterable will call the completion handler
1919
* automatically if you pass one. If you handle completionHandler in the app code, pass a nil value to this argument.
2020
*/
21-
@objc public static func application(_ application: UIApplication,
22-
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
23-
fetchCompletionHandler completionHandler: ((UIBackgroundFetchResult) -> Void)?) {
21+
@objc
22+
public static func application(_ application: UIApplication,
23+
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
24+
fetchCompletionHandler completionHandler: ((UIBackgroundFetchResult) -> Void)?) {
2425
ITBInfo()
25-
implementation?.application(application, didReceiveRemoteNotification: userInfo, fetchCompletionHandler: completionHandler)
26+
27+
implementation?.application(application,
28+
didReceiveRemoteNotification: userInfo,
29+
fetchCompletionHandler: completionHandler)
2630
}
2731

2832
/**
@@ -35,9 +39,15 @@ import UserNotifications
3539
* automatically if you pass one. If you handle completionHandler in the app code, pass a nil value to this argument.
3640
*/
3741
@available(iOS 10.0, *)
38-
@objc(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:) public static func userNotificationCenter(_ center: UNUserNotificationCenter?, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: (() -> Void)?) {
42+
@objc(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)
43+
public static func userNotificationCenter(_ center: UNUserNotificationCenter?,
44+
didReceive response: UNNotificationResponse,
45+
withCompletionHandler completionHandler: (() -> Void)?) {
3946
ITBInfo()
40-
implementation?.userNotificationCenter(center, didReceive: UserNotificationResponse(response: response), withCompletionHandler: completionHandler)
47+
48+
implementation?.userNotificationCenter(center,
49+
didReceive: UserNotificationResponse(response: response),
50+
withCompletionHandler: completionHandler)
4151
}
4252

4353
// MARK: Private

swift-sdk/IterableConfig.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ import Foundation
3838
/**
3939
* This method is called when new in-app message is available.
4040
* The default behavior is to `show` if you don't override this method.
41-
* - parameter message: `IterableInAppMessage` object containing information regarding inApp to display
42-
* - returns: Return `show` to show the inApp or `skip` to skip this.
41+
* - parameter message: `IterableInAppMessage` object containing information regarding in-app to display
42+
* - returns: Return `show` to show the in-app or `skip` to skip this.
4343
*/
4444
@objc(onNewMessage:) func onNew(message: IterableInAppMessage) -> InAppShowResponse
4545
}
@@ -125,12 +125,12 @@ import Foundation
125125
/// It will log everything >= minLogLevel
126126
public var logDelegate: IterableLogDelegate = DefaultLogDelegate()
127127

128-
/// Implement this protocol to override default inApp behavior.
129-
/// By default, every single inApp will be shown as soon as it is available.
130-
/// If more than 1 inApp is available, we show the first.
128+
/// Implement this protocol to override default in-app behavior.
129+
/// By default, every single in-app will be shown as soon as it is available.
130+
/// If more than 1 in-app is available, we show the first.
131131
public var inAppDelegate: IterableInAppDelegate = DefaultInAppDelegate()
132132

133-
/// How many seconds to wait before showing the next inApp, if there are more than one present
133+
/// How many seconds to wait before showing the next in-app, if there are more than one present
134134
public var inAppDisplayInterval: Double = 30.0
135135

136136
/// These are internal. Do not change

swift-sdk/IterableMessaging.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
// Created by Tapash Majumder on 11/5/18.
33
// Copyright © 2018 Iterable. All rights reserved.
44
//
5-
// This file contains InApp and Inbox messaging classes.
5+
6+
// This file contains In-app and Inbox messaging classes.
67

78
import Foundation
89
import UIKit
910

10-
/// `show` to show the inApp otherwise `skip` to skip.
11+
/// `show` to show the in-app otherwise `skip` to skip.
1112
@objc public enum InAppShowResponse: Int {
1213
case show
1314
case skip
@@ -58,8 +59,8 @@ public extension Notification.Name {
5859
@objcMembers open class DefaultInAppDelegate: IterableInAppDelegate {
5960
public init() {}
6061

61-
/// By default, every single inApp will be shown as soon as it is available.
62-
/// If more than 1 inApp is available, we show the first showable one.
62+
/// By default, every single in-app will be shown as soon as it is available.
63+
/// If more than 1 in-app is available, we show the first showable one.
6364
open func onNew(message _: IterableInAppMessage) -> InAppShowResponse {
6465
ITBInfo()
6566
return .show
@@ -83,7 +84,7 @@ public extension Notification.Name {
8384
public let edgeInsets: UIEdgeInsets
8485
/// Background alpha setting
8586
public let backgroundAlpha: Double
86-
/// The html to display
87+
/// The HTML to display
8788
public let html: String
8889

8990
// Internal
@@ -111,9 +112,9 @@ public extension Notification.Name {
111112
}
112113
}
113114

114-
/// `immediate` will try to display the inApp automatically immediately
115-
/// `event` is used for Push to InApp
116-
/// `never` will not display the inApp automatically via the SDK
115+
/// `immediate` will try to display the in-app automatically immediately
116+
/// `event` is used for Push to in-app
117+
/// `never` will not display the in-app automatically via the SDK
117118
@objc public enum IterableInAppTriggerType: Int, Codable {
118119
case immediate
119120
case event

0 commit comments

Comments
 (0)