-
Notifications
You must be signed in to change notification settings - Fork 1
/
NotificationViewController.m
60 lines (44 loc) · 2.08 KB
/
NotificationViewController.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#import "NotificationViewController.h"
#import <UserNotificationsUI/UserNotificationsUI.h>
#import <InsiderMobileAdvancedNotification/iCarousel.h>
#import <InsiderMobileAdvancedNotification/InsiderPushNotification.h>
@interface NotificationViewController () <UNNotificationContentExtension, iCarouselDelegate, iCarouselDataSource>
@property (nonatomic, weak) IBOutlet iCarousel *carousel;
@end
// FIXME: Please change with your app group.
static NSString *APP_GROUP = @"group.com.useinsider.InsiderDemo";
@implementation NotificationViewController
@synthesize carousel;
-(void)viewDidLoad {
[super viewDidLoad];
}
-(void)didReceiveNotification:(UNNotification *)notification {
[InsiderPushNotification interactivePushLoad:APP_GROUP superView:self.view notification:notification];
carousel.type = iCarouselTypeRotary;
[carousel reloadData];
[InsiderPushNotification interactivePushDidReceiveNotification];
}
-(NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel {
return [InsiderPushNotification getNumberOfSlide];
}
-(UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view {
return [InsiderPushNotification getSlide:index reusingView:view superView:self.view];
}
-(void)dealloc {
carousel.delegate = nil;
carousel.dataSource = nil;
}
-(CGFloat)carouselItemWidth:(iCarousel *)carousel {
return [InsiderPushNotification getItemWidth];
}
-(void)didReceiveNotificationResponse:(UNNotificationResponse *)response
completionHandler:(void (^)(UNNotificationContentExtensionResponseOption option))completion {
if ([response.actionIdentifier isEqualToString:@"insider_int_push_next"]){
[carousel scrollToItemAtIndex:[InsiderPushNotification didReceiveNotificationResponse:[carousel currentItemIndex]] animated:true];
completion(UNNotificationContentExtensionResponseOptionDoNotDismiss);
} else {
[InsiderPushNotification logPlaceholderClick:response];
completion(UNNotificationContentExtensionResponseOptionDismissAndForwardAction);
}
}
@end