Skip to content

Commit

Permalink
Notifications: Add support for app extension notifications (#103)
Browse files Browse the repository at this point in the history
* Add notification function for app extension

* Update notification register request
  • Loading branch information
anian03 authored Nov 19, 2024
1 parent 689cd5c commit ffa2788
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/PushNotifications/PushNotificationHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ import UserNotifications

public class PushNotificationHandler {

public static func extractNotification(from payload: String, iv: String) async -> UNMutableNotificationContent? {
log.verbose("Notification received with payload: \(payload)")

guard let notification = PushNotificationCipher.decrypt(payload: payload, iv: iv) else {
log.verbose("Notification could not be decrypted.")
return nil
}

return await prepareNotification(notification)
}

public static func handle(payload: String, iv: String) {
log.verbose("Notification received with payload: \(payload)")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class PushNotificationServiceImpl: PushNotificationService {

var token: String
var deviceType = "APNS"
var apiType = 1

var method: HTTPMethod {
return .post
Expand Down

0 comments on commit ffa2788

Please sign in to comment.