-
Notifications
You must be signed in to change notification settings - Fork 1
/
NotificationService.m
37 lines (26 loc) · 1.3 KB
/
NotificationService.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#import "NotificationService.h"
#import <InsiderMobileAdvancedNotification/InsiderPushNotification.h>
@interface NotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@end
// FIXME: Please change with your app group.
static NSString *APP_GROUP = @"group.com.useinsider.InsiderDemo";
@implementation NotificationService
-(void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
// MARK: You can customize these.
NSString *nextButtonText = @">>";
NSString *goToAppText = @"Launch App";
[InsiderPushNotification showInsiderRichPush:request appGroup:APP_GROUP nextButtonText:nextButtonText goToAppText:goToAppText success:^(UNNotificationAttachment *attachment) {
if (attachment) {
self.bestAttemptContent.attachments = [NSArray arrayWithObject:attachment];
}
self.contentHandler(self.bestAttemptContent);
}];
}
-(void)serviceExtensionTimeWillExpire {
self.contentHandler(self.bestAttemptContent);
}
@end