@@ -32,11 +32,12 @@ public protocol LegacyInAppMessagingProtocol: AnyObject, Sendable {
32
32
33
33
protocol InternalLegacyInAppMessagingProtocol : LegacyInAppMessagingProtocol {
34
34
#if !os(tvOS)
35
- func receivedNotificationResponse( _ response: UNNotificationResponse , completionHandler : @ Sendable @ escaping ( ) -> Void )
35
+ func receivedNotificationResponse( _ response: UNNotificationResponse ) async
36
36
#endif
37
37
38
- func receivedRemoteNotification( _ notification: [ AnyHashable : Any ] ,
39
- completionHandler: @Sendable @escaping ( UIBackgroundFetchResult ) -> Void )
38
+ func receivedRemoteNotification(
39
+ _ notification: AirshipJSON // wrapped [AnyHashable : Any]
40
+ ) async -> UIBackgroundFetchResult
40
41
}
41
42
42
43
final class LegacyInAppMessaging : LegacyInAppMessagingProtocol , @unchecked Sendable {
@@ -209,47 +210,43 @@ final class LegacyInAppMessaging: LegacyInAppMessagingProtocol, @unchecked Senda
209
210
extension LegacyInAppMessaging : InternalLegacyInAppMessagingProtocol {
210
211
211
212
#if !os(tvOS)
212
- func receivedNotificationResponse( _ response: UNNotificationResponse , completionHandler : @ Sendable @ escaping ( ) -> Void ) {
213
+ func receivedNotificationResponse( _ response: UNNotificationResponse ) async {
213
214
let userInfo = response. notification. request. content. userInfo
214
215
215
216
guard
216
217
userInfo. keys. contains ( Keys . incomingMessageKey. rawValue) ,
217
218
let messageID = userInfo [ " _ " ] as? String ,
218
219
messageID == self . pendingMessageID
219
220
else {
220
- completionHandler ( )
221
221
return
222
222
}
223
223
224
224
self . pendingMessageID = nil
225
225
226
- Task {
227
- if await self . scheduleExists ( identifier: messageID) {
228
- AirshipLogger . debug ( " Pending in-app message replaced " )
229
- self . analytics. recordDirectOpenEvent ( scheduleID: messageID)
230
- }
231
-
232
- await self . cancelSchedule ( identifier: messageID)
233
- completionHandler ( )
226
+ if await self . scheduleExists ( identifier: messageID) {
227
+ AirshipLogger . debug ( " Pending in-app message replaced " )
228
+ self . analytics. recordDirectOpenEvent ( scheduleID: messageID)
234
229
}
230
+
231
+ await self . cancelSchedule ( identifier: messageID)
235
232
}
236
233
#endif
237
234
238
- func receivedRemoteNotification( _ notification: [ AnyHashable : Any ] ,
239
- completionHandler : @ Sendable @ escaping ( UIBackgroundFetchResult ) -> Void ) {
240
- guard let payload = notification [ Keys . incomingMessageKey . rawValue ] as? [ String : Any ] else {
241
- completionHandler ( . noData )
242
- return
235
+ func receivedRemoteNotification( _ notification: AirshipJSON ) async -> UIBackgroundFetchResult {
236
+ guard
237
+ let userInfo = notification. unWrap ( ) as? [ AnyHashable : Any ] ,
238
+ let payload = userInfo [ Keys . incomingMessageKey . rawValue ] as? [ String : Any ] else {
239
+ return . noData
243
240
}
244
241
245
- let overrideId = notification [ " _ " ] as? String
242
+ let overrideId = userInfo [ " _ " ] as? String
246
243
let messageCenterAction : AirshipJSON ?
247
244
248
245
if
249
- let actionRaw = notification [ Keys . messageCenterActionKey. rawValue] as? [ String : Any ] ,
246
+ let actionRaw = userInfo [ Keys . messageCenterActionKey. rawValue] as? [ String : Any ] ,
250
247
let action = try ? AirshipJSON . wrap ( actionRaw) {
251
248
messageCenterAction = action
252
- } else if let messageId = notification [ Keys . messageCenterActionKey. rawValue] as? String {
249
+ } else if let messageId = userInfo [ Keys . messageCenterActionKey. rawValue] as? String {
253
250
messageCenterAction = . object( [ Keys . messageCenterActionKey. rawValue: . string( messageId) ] )
254
251
} else {
255
252
messageCenterAction = nil
@@ -263,13 +260,10 @@ extension LegacyInAppMessaging: InternalLegacyInAppMessagingProtocol {
263
260
)
264
261
265
262
if let message = message {
266
- Task {
267
- await schedule ( message: message)
268
- completionHandler ( . noData)
269
- }
270
- } else {
271
- completionHandler ( . noData)
263
+ await schedule ( message: message)
272
264
}
265
+
266
+ return . noData
273
267
}
274
268
275
269
private enum Keys : String {
0 commit comments