Skip to content

Instantly share code, notes, and snippets.

@marcinwasowicz
Created February 23, 2023 13:31
Show Gist options
  • Save marcinwasowicz/193fb4916b277537a4b7f9e88a456e06 to your computer and use it in GitHub Desktop.
Save marcinwasowicz/193fb4916b277537a4b7f9e88a456e06 to your computer and use it in GitHub Desktop.
Test NotificationService.mm
#import "NotificationService.h"
#import "TemporaryMessageStorage.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.contentHandler([[UNNotificationContent alloc] init]);
}
- (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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment