@@ -121,15 +121,15 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
121
121
}
122
122
}
123
123
124
- func remove( message: IterableInAppMessage , location: InAppLocation ) {
124
+ func remove( message: IterableInAppMessage , location: InAppLocation , onCompletion : OnCompletionHandler ? ) {
125
125
ITBInfo ( )
126
-
126
+ self . completionHandler = onCompletion
127
127
removePrivate ( message: message, location: location)
128
128
}
129
129
130
- func remove( message: IterableInAppMessage , location: InAppLocation , source: InAppDeleteSource ) {
130
+ func remove( message: IterableInAppMessage , location: InAppLocation , source: InAppDeleteSource , onCompletion : OnCompletionHandler ? ) {
131
131
ITBInfo ( )
132
-
132
+ self . completionHandler = onCompletion
133
133
removePrivate ( message: message, location: location, source: source)
134
134
}
135
135
@@ -139,11 +139,15 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
139
139
removePrivate ( message: message, location: location, source: source, inboxSessionId: inboxSessionId)
140
140
}
141
141
142
- func set( read: Bool , forMessage message: IterableInAppMessage ) {
142
+ func set( read: Bool , forMessage message: IterableInAppMessage , onCompletion: OnCompletionHandler ? ) {
143
+ self . completionHandler = onCompletion
143
144
updateMessage ( message, read: read) . onSuccess { [ weak self] _ in
145
+ self ? . completionHandler ? ( true )
144
146
self ? . callbackQueue. async { [ weak self] in
145
147
self ? . notificationCenter. post ( name: . iterableInboxChanged, object: self , userInfo: nil )
146
148
}
149
+ } . onError { [ weak self] _ in
150
+ self ? . completionHandler ? ( false )
147
151
}
148
152
}
149
153
@@ -183,7 +187,7 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
183
187
}
184
188
}
185
189
186
- func remove( message: IterableInAppMessage ) {
190
+ func remove( message: IterableInAppMessage , onCompletion : OnCompletionHandler ? ) {
187
191
ITBInfo ( )
188
192
189
193
removePrivate ( message: message)
@@ -470,8 +474,12 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
470
474
location: location,
471
475
source: source,
472
476
inboxSessionId: inboxSessionId,
473
- onSuccess: nil ,
474
- onFailure: nil )
477
+ onSuccess: { ( _ data: [ AnyHashable : Any ] ? ) in
478
+ self . completionHandler ? ( true )
479
+ } ,
480
+ onFailure: { ( _ reason: String ? , _ data: Data ? ) in
481
+ self . completionHandler ? ( false )
482
+ } )
475
483
callbackQueue. async { [ weak self] in
476
484
self ? . notificationCenter. post ( name: . iterableInboxChanged, object: self , userInfo: nil )
477
485
}
@@ -533,6 +541,7 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
533
541
private var lastSyncTime : Date ?
534
542
private var moveToForegroundSyncInterval : Double = 1.0 * 60.0 // don't sync within sixty seconds
535
543
private var autoDisplayPaused = false
544
+ private var completionHandler : OnCompletionHandler ? = nil
536
545
}
537
546
538
547
extension InAppManager : InAppNotifiable {
0 commit comments