summaryrefslogtreecommitdiff
path: root/JuickPush/NotificationService.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2020-09-16 17:39:47 +0300
committerGravatar Vitaly Takmazov2020-12-10 18:59:55 +0300
commit77cd2d89c49285f02efabb42c46a4f81e61d5e6f (patch)
tree8f11e91d4c60ec3d493d6b64e8f35bf8985e9091 /JuickPush/NotificationService.m
parentaa6e2444af3bb07180550b646ad8f0d3ca78ddfb (diff)
NotificationService rewritten in Swift, added dummy test target
Diffstat (limited to 'JuickPush/NotificationService.m')
-rw-r--r--JuickPush/NotificationService.m46
1 files changed, 0 insertions, 46 deletions
diff --git a/JuickPush/NotificationService.m b/JuickPush/NotificationService.m
deleted file mode 100644
index 82dead8..0000000
--- a/JuickPush/NotificationService.m
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// NotificationService.m
-// JuickPush
-//
-// Created by Vitaly Takmazov on 18/10/2018.
-// Copyright © 2018 com.juick. 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];
-
- NSURL *avatarURL = [NSURL URLWithString:request.content.userInfo[@"avatarUrl"]];
-
- NSURLSession * downloadSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
-
- [[downloadSession downloadTaskWithURL:avatarURL completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) {
- if (!error) {
- NSError *err = nil;
- NSString *temporaryDirectory = [NSTemporaryDirectory() stringByAppendingPathComponent:[response suggestedFilename]];
- [[NSFileManager defaultManager] moveItemAtPath:location.path toPath:temporaryDirectory error:&err];
- UNNotificationAttachment *avatarAttachment = [UNNotificationAttachment attachmentWithIdentifier:avatarURL.lastPathComponent URL:[NSURL fileURLWithPath:temporaryDirectory] options:nil error:&err];
- self.bestAttemptContent.attachments = @[avatarAttachment];
- self.contentHandler(self.bestAttemptContent);
- }
- }] resume];
-}
-
-- (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