mirror of
https://github.com/luxfi/wallet.git
synced 2026-10-30 15:13:19 +00:00
Copies apps/extension, apps/mobile and 10 pkgs (wallet, ui, config, utilities, sessions, gating, notifications, analytics, eslint-config, prices) into a standalone pnpm workspace. Resolves merge conflict markers in extension and mobile package.json files, strips build artifacts (.wxt, .output, Pods).
35 lines
1.8 KiB
Swift
35 lines
1.8 KiB
Swift
import UserNotifications
|
|
import OneSignalExtension
|
|
|
|
class NotificationService: UNNotificationServiceExtension {
|
|
|
|
var contentHandler: ((UNNotificationContent) -> Void)?
|
|
var receivedRequest: UNNotificationRequest!
|
|
var bestAttemptContent: UNMutableNotificationContent?
|
|
|
|
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
|
self.receivedRequest = request
|
|
self.contentHandler = contentHandler
|
|
self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
|
|
|
|
if let bestAttemptContent = bestAttemptContent {
|
|
/* DEBUGGING: Uncomment the 2 lines below to check this extension is executing
|
|
Note, this extension only runs when mutable-content is set
|
|
Setting an attachment or action buttons automatically adds this */
|
|
// print("Running NotificationServiceExtension")
|
|
// bestAttemptContent.body = "[Modified] " + bestAttemptContent.body
|
|
|
|
OneSignalExtension.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler)
|
|
}
|
|
}
|
|
|
|
override func serviceExtensionTimeWillExpire() {
|
|
// Called just before the extension will be terminated by the system.
|
|
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
|
|
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
|
|
OneSignalExtension.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
|
|
contentHandler(bestAttemptContent)
|
|
}
|
|
}
|
|
}
|