Sha256: 6d5ee985390403dd07151a8f63704776ebb5c590e4f68d0dffdf62da38eb44fd

Contents?: true

Size: 1.29 KB

Versions: 17

Compression:

Stored size: 1.29 KB

Contents

//
//  NotificationService.swift
//
//  NotificationService
//
//  Created by YKRPC_AUTHOR_NAME on YKRPC_CREATE_DATE.
//

import UserNotifications

class NotificationService: UNNotificationServiceExtension {

    var contentHandler: ((UNNotificationContent) -> Void)?
    var bestAttemptContent: UNMutableNotificationContent?

    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        self.contentHandler = contentHandler
        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
        
        if let bestAttemptContent = bestAttemptContent {
            // Modify the notification content here...
            bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"
            
            contentHandler(bestAttemptContent)
        }
    }
    
    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 {
            contentHandler(bestAttemptContent)
        }
    }

}

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
cocoapods-ykutility-3.0.4 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-3.0.3 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-3.0.2 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-3.0.1 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-3.0.0 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-2.0.9 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-2.0.8 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-2.0.7 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-2.0.6 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-2.0.5 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-2.0.4 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-2.0.3 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-2.0.2 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-2.0.1 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-2.0.0 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-1.0.2 configPodTemplate/example/NotificationService/NotificationService.swift
cocoapods-ykutility-1.0.1 configPodTemplate/example/NotificationService/NotificationService.swift