diff --git a/PpgCoreSDK/PpgCoreNotificationServiceExtension.swift b/PpgCoreSDK/PpgCoreNotificationServiceExtension.swift index 026ade5..c3904ca 100644 --- a/PpgCoreSDK/PpgCoreNotificationServiceExtension.swift +++ b/PpgCoreSDK/PpgCoreNotificationServiceExtension.swift @@ -24,6 +24,7 @@ open class PpgCoreNotificationServiceExtension: UNNotificationServiceExtension { let dataNotification = NotificationFactory.createData(content: request.content) let newContent = dataNotification.toUNNotificationMutableContent() eventService.send(delivered: dataNotification.createDeliveredEvent()) + onExternalData(data: dataNotification.externalData) contentHandler(newContent); return newContent @@ -31,6 +32,7 @@ open class PpgCoreNotificationServiceExtension: UNNotificationServiceExtension { PpgCoreLogger.info("Got silent message as normal remote notification"); let silentNotification = NotificationFactory.createSilent(content: request.content) eventService.send(delivered: silentNotification.createDeliveredEvent()) + onExternalData(data: silentNotification.externalData) let newContent = silentNotification.toUNNotificationMutableContent() return newContent @@ -51,5 +53,9 @@ open class PpgCoreNotificationServiceExtension: UNNotificationServiceExtension { contentHandler(bestAttemptContent) } } + + open func onExternalData(data: String) -> Void { + + } } diff --git a/PpgCoreSDK/Services/EventService.swift b/PpgCoreSDK/Services/EventService.swift index d1b5d3a..af6af27 100644 --- a/PpgCoreSDK/Services/EventService.swift +++ b/PpgCoreSDK/Services/EventService.swift @@ -37,14 +37,14 @@ class EventService { } func internalSend(data: Data, contextId: String, type: EventType, completionHandler: @escaping () -> Void) { - var request = URLRequest( + var request: URLRequest = URLRequest( url: URL(string: "\(endpoint)/context/\(contextId.lowercased())/events/\(getActionByType(type: type))")! ) request.setValue("application/json", forHTTPHeaderField: "Content-Type") request.httpMethod = "POST" request.httpBody = data - + URLSession.shared.dataTask(with: request) { data, response, error in if error != nil { PpgCoreLogger.info(error?.localizedDescription ?? "Unknown error") diff --git a/examples/sdkdemo/NSE/NotificationService.swift b/examples/sdkdemo/NSE/NotificationService.swift index af1b218..8738c39 100644 --- a/examples/sdkdemo/NSE/NotificationService.swift +++ b/examples/sdkdemo/NSE/NotificationService.swift @@ -9,5 +9,7 @@ import UserNotifications import PpgCoreSDK class NotificationService: PpgCoreNotificationServiceExtension { - + override func onExternalData(data: String) { + PpgCoreLogger.error("NSE RECEIVED EXTERNAL DATA" + data) + } } diff --git a/examples/sdkdemo/sdkdemo.xcworkspace/xcuserdata/worotyns.xcuserdatad/UserInterfaceState.xcuserstate b/examples/sdkdemo/sdkdemo.xcworkspace/xcuserdata/worotyns.xcuserdatad/UserInterfaceState.xcuserstate index b0c0a15..a04b405 100644 Binary files a/examples/sdkdemo/sdkdemo.xcworkspace/xcuserdata/worotyns.xcuserdatad/UserInterfaceState.xcuserstate and b/examples/sdkdemo/sdkdemo.xcworkspace/xcuserdata/worotyns.xcuserdatad/UserInterfaceState.xcuserstate differ