@@ -19,14 +19,24 @@ protocol IterableInternalInAppManagerProtocol: IterableInAppManagerProtocol, InA
19
19
/// - parameter inboxSessionId: The ID of the inbox session that the message originates from.
20
20
func handleClick( clickedUrl url: URL ? , forMessage message: IterableInAppMessage , location: InAppLocation , inboxSessionId: String ? )
21
21
22
+
22
23
/// - parameter message: The message to remove.
23
24
/// - parameter location: The location from where this message was shown. `inbox` or `inApp`.
24
25
/// - parameter source: The source of deletion `inboxSwipe` or `deleteButton`.`
25
26
/// - parameter inboxSessionId: The ID of the inbox session that the message originates from.
26
27
func remove( message: IterableInAppMessage , location: InAppLocation , source: InAppDeleteSource , inboxSessionId: String ? )
28
+
29
+ /// - parameter message: The message to remove.
30
+ /// - parameter location: The location from where this message was shown. `inbox` or `inApp`.
31
+ /// - parameter source: The source of deletion `inboxSwipe` or `deleteButton`.`
32
+ /// - parameter inboxSessionId: The ID of the inbox session that the message originates from.
33
+ /// - parameter successHandler: The callback which returns `success.
34
+ /// - parameter failureHandler: The callback which returns `failure.
35
+ func remove( message: IterableInAppMessage , location: InAppLocation , source: InAppDeleteSource , inboxSessionId: String ? , successHandler: OnSuccessHandler ? , failureHandler: OnFailureHandler ? )
27
36
}
28
37
29
38
class InAppManager : NSObject , IterableInternalInAppManagerProtocol {
39
+
30
40
init ( requestHandler: RequestHandlerProtocol ,
31
41
deviceMetadata: DeviceMetadata ,
32
42
fetcher: InAppFetcherProtocol ,
@@ -124,26 +134,44 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
124
134
func remove( message: IterableInAppMessage , location: InAppLocation ) {
125
135
ITBInfo ( )
126
136
127
- removePrivate ( message: message, location: location)
137
+ remove ( message: message, location: location, successHandler: nil , failureHandler: nil )
138
+ }
139
+
140
+ func remove( message: IterableInAppMessage , location: InAppLocation , successHandler: OnSuccessHandler ? = nil , failureHandler: OnFailureHandler ? = nil ) {
141
+ removePrivate ( message: message, location: location, successHandler: successHandler, failureHandler: failureHandler)
128
142
}
129
143
130
144
func remove( message: IterableInAppMessage , location: InAppLocation , source: InAppDeleteSource ) {
131
- ITBInfo ( )
145
+ remove ( message: message, location: location, source: source, successHandler: nil , failureHandler: nil )
146
+ }
147
+
148
+ func remove( message: IterableInAppMessage , location: InAppLocation , source: InAppDeleteSource , successHandler: OnSuccessHandler ? = nil , failureHandler: OnFailureHandler ? = nil ) {
132
149
133
- removePrivate ( message: message, location: location, source: source)
150
+ removePrivate ( message: message, location: location, source: source, successHandler : successHandler , failureHandler : failureHandler )
134
151
}
135
152
136
- func remove( message: IterableInAppMessage , location: InAppLocation , source: InAppDeleteSource , inboxSessionId: String ? = nil ) {
153
+ func remove( message: IterableInAppMessage , location: InAppLocation , source: InAppDeleteSource , inboxSessionId: String ? ) {
137
154
ITBInfo ( )
138
155
139
- removePrivate ( message: message, location: location, source: source, inboxSessionId: inboxSessionId)
156
+ remove ( message: message, location: location, source: source, inboxSessionId: inboxSessionId, successHandler: nil , failureHandler: nil )
157
+ }
158
+
159
+ func remove( message: IterableInAppMessage , location: InAppLocation , source: InAppDeleteSource , inboxSessionId: String ? = nil , successHandler: OnSuccessHandler ? = nil , failureHandler: OnFailureHandler ? = nil ) {
160
+ removePrivate ( message: message, location: location, source: source, inboxSessionId: inboxSessionId, successHandler: successHandler, failureHandler: failureHandler)
140
161
}
141
162
142
163
func set( read: Bool , forMessage message: IterableInAppMessage ) {
164
+ set ( read: read, forMessage: message, successHandler: nil , failureHandler: nil )
165
+ }
166
+
167
+ func set( read: Bool , forMessage message: IterableInAppMessage , successHandler: OnSuccessHandler ? = nil , failureHandler: OnFailureHandler ? = nil ) {
143
168
updateMessage ( message, read: read) . onSuccess { [ weak self] _ in
169
+ successHandler ? ( [ : ] )
144
170
self ? . callbackQueue. async { [ weak self] in
145
171
self ? . notificationCenter. post ( name: . iterableInboxChanged, object: self , userInfo: nil )
146
172
}
173
+ } . onError { [ weak self] _ in
174
+ failureHandler ? ( self ? . description, nil )
147
175
}
148
176
}
149
177
@@ -185,8 +213,12 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
185
213
186
214
func remove( message: IterableInAppMessage ) {
187
215
ITBInfo ( )
188
-
189
- removePrivate ( message: message)
216
+
217
+ remove ( message: message, successHandler: nil , failureHandler: nil )
218
+ }
219
+
220
+ func remove( message: IterableInAppMessage , successHandler: OnSuccessHandler ? , failureHandler: OnFailureHandler ? ) {
221
+ removePrivate ( message: message, location: . inApp, source: nil , successHandler: successHandler, failureHandler: failureHandler)
190
222
}
191
223
192
224
// MARK: - Private/Internal
@@ -462,16 +494,17 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
462
494
private func removePrivate( message: IterableInAppMessage ,
463
495
location: InAppLocation = . inApp,
464
496
source: InAppDeleteSource ? = nil ,
465
- inboxSessionId: String ? = nil ) {
497
+ inboxSessionId: String ? = nil ,
498
+ successHandler: OnSuccessHandler ? = nil ,
499
+ failureHandler: OnFailureHandler ? = nil ) {
466
500
ITBInfo ( )
467
-
468
501
updateMessage ( message, didProcessTrigger: true , consumed: true )
469
502
requestHandler? . inAppConsume ( message: message,
470
503
location: location,
471
504
source: source,
472
505
inboxSessionId: inboxSessionId,
473
- onSuccess: nil ,
474
- onFailure: nil )
506
+ onSuccess: successHandler ,
507
+ onFailure: failureHandler )
475
508
callbackQueue. async { [ weak self] in
476
509
self ? . notificationCenter. post ( name: . iterableInboxChanged, object: self , userInfo: nil )
477
510
}
0 commit comments