You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.2 KiB
37 lines
1.2 KiB
1 year ago
|
//
|
||
|
// NotificationService.m
|
||
|
// TXNotificationSerExtension
|
||
|
//
|
||
|
// Created by ecell on 2023/5/12.
|
||
|
// Copyright © 2023 xTT. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "NotificationService.h"
|
||
|
|
||
|
@interface NotificationService ()
|
||
|
|
||
|
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
|
||
|
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation NotificationService
|
||
|
|
||
|
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
|
||
|
self.contentHandler = contentHandler;
|
||
|
self.bestAttemptContent = [request.content mutableCopy];
|
||
|
|
||
|
// Modify the notification content here...
|
||
|
self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [modified]", self.bestAttemptContent.title];
|
||
|
|
||
|
self.contentHandler(self.bestAttemptContent);
|
||
|
}
|
||
|
|
||
|
- (void)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.
|
||
|
self.contentHandler(self.bestAttemptContent);
|
||
|
}
|
||
|
|
||
|
@end
|