@@ -11,6 +11,7 @@ typedef NS_ENUM(NSInteger, CTNotificationContentType) {
11
11
CTNotificationContentTypeAutoCarousel = 3 ,
12
12
CTNotificationContentTypeManualCarousel = 4 ,
13
13
CTNotificationContentTypeTimerTemplate = 5 ,
14
+ CTNotificationContentTypeZeroBezel = 6
14
15
};
15
16
16
17
static NSString * const kTemplateId = @" pt_id" ;
@@ -23,12 +24,15 @@ typedef NS_ENUM(NSInteger, CTNotificationContentType) {
23
24
static NSString * const kSingleMediaURL = @" ct_mediaUrl" ;
24
25
static NSString * const kJSON = @" pt_json" ;
25
26
static NSString * const kDeeplinkURL = @" wzrk_dl" ;
27
+ static NSString * const kTemplateZeroBezel = @" pt_zero_bezel" ;
26
28
27
29
@interface CTNotificationViewController () <UNNotificationContentExtension>
28
30
29
31
@property (nonatomic , assign ) CTNotificationContentType contentType;
30
32
@property (nonatomic , strong , readwrite ) BaseCTNotificationContentViewController *contentViewController;
31
33
@property (nonatomic ) NSString *jsonString;
34
+ @property (nonatomic ) NSDictionary *content;
35
+ @property (nonatomic ) UNNotification *notification;
32
36
33
37
@end
34
38
@@ -41,17 +45,19 @@ - (void)viewDidLoad {
41
45
}
42
46
43
47
- (void )didReceiveNotification : (UNNotification *)notification {
44
- NSDictionary *content = notification.request .content .userInfo ;
45
- [self updateContentType: content];
48
+ _content = notification.request .content .userInfo ;
49
+ _notification = notification;
50
+
51
+ [self updateContentType: _content];
46
52
47
53
switch (self.contentType ) {
48
54
case CTNotificationContentTypeContentSlider: {
49
55
CTContentSliderController *contentController = [[CTContentSliderController alloc ] init ];
50
- [contentController setData: content [kContentSlider ]];
56
+ [contentController setData: _content [kContentSlider ]];
51
57
[contentController setTemplateCaption: notification.request.content.title];
52
58
[contentController setTemplateSubcaption: notification.request.content.body];
53
- if (content [kDeeplinkURL ] != nil ) {
54
- [contentController setDeeplinkURL: content [kDeeplinkURL ]];
59
+ if (_content [kDeeplinkURL ] != nil ) {
60
+ [contentController setDeeplinkURL: _content [kDeeplinkURL ]];
55
61
}
56
62
[self addChildViewController: contentController];
57
63
contentController.view .frame = self.view .frame ;
@@ -63,10 +69,10 @@ - (void)didReceiveNotification:(UNNotification *)notification {
63
69
CTSingleMediaController *contentController = [[CTSingleMediaController alloc ] init ];
64
70
[contentController setCaption: notification.request.content.title];
65
71
[contentController setSubCaption: notification.request.content.body];
66
- [contentController setMediaType: content [kSingleMediaType ]];
67
- [contentController setMediaURL: content [kSingleMediaURL ]];
68
- if (content [kDeeplinkURL ] != nil ) {
69
- [contentController setDeeplinkURL: content [kDeeplinkURL ]];
72
+ [contentController setMediaType: _content [kSingleMediaType ]];
73
+ [contentController setMediaURL: _content [kSingleMediaURL ]];
74
+ if (_content [kDeeplinkURL ] != nil ) {
75
+ [contentController setDeeplinkURL: _content [kDeeplinkURL ]];
70
76
}
71
77
[self addChildViewController: contentController];
72
78
contentController.view .frame = self.view .frame ;
@@ -76,61 +82,30 @@ - (void)didReceiveNotification:(UNNotification *)notification {
76
82
break ;
77
83
case CTNotificationContentTypeBasicTemplate: {
78
84
CTCarouselController *contentController = [[CTCarouselController alloc ] init ];
79
- [contentController setData: self .jsonString];
80
- [contentController setTemplateCaption: notification.request.content.title];
81
- [contentController setTemplateSubcaption: notification.request.content.body];
82
- if (content[kDeeplinkURL ] != nil ) {
83
- [contentController setDeeplinkURL: content[kDeeplinkURL ]];
84
- }
85
85
[contentController setTemplateType: kTemplateBasic ];
86
- [self addChildViewController: contentController];
87
- contentController.view .frame = self.view .frame ;
88
- [self .view addSubview: contentController.view];
89
- self.contentViewController = contentController;
86
+ [self setupContentController: contentController];
90
87
}
91
88
break ;
92
89
case CTNotificationContentTypeAutoCarousel: {
93
90
CTCarouselController *contentController = [[CTCarouselController alloc ] init ];
94
- [contentController setData: self .jsonString];
95
- [contentController setTemplateCaption: notification.request.content.title];
96
- [contentController setTemplateSubcaption: notification.request.content.body];
97
- if (content[kDeeplinkURL ] != nil ) {
98
- [contentController setDeeplinkURL: content[kDeeplinkURL ]];
99
- }
100
91
[contentController setTemplateType: kTemplateAutoCarousel ];
101
- [self addChildViewController: contentController];
102
- contentController.view .frame = self.view .frame ;
103
- [self .view addSubview: contentController.view];
104
- self.contentViewController = contentController;
92
+ [self setupContentController: contentController];
105
93
}
106
94
break ;
107
95
case CTNotificationContentTypeManualCarousel: {
108
96
CTCarouselController *contentController = [[CTCarouselController alloc ] init ];
109
- [contentController setData: self .jsonString];
110
- [contentController setTemplateCaption: notification.request.content.title];
111
- [contentController setTemplateSubcaption: notification.request.content.body];
112
- if (content[kDeeplinkURL ] != nil ) {
113
- [contentController setDeeplinkURL: content[kDeeplinkURL ]];
114
- }
115
97
[contentController setTemplateType: kTemplateManualCarousel ];
116
- [self addChildViewController: contentController];
117
- contentController.view .frame = self.view .frame ;
118
- [self .view addSubview: contentController.view];
119
- self.contentViewController = contentController;
98
+ [self setupContentController: contentController];
120
99
}
121
100
break ;
122
101
case CTNotificationContentTypeTimerTemplate: {
123
102
CTTimerTemplateController *contentController = [[CTTimerTemplateController alloc ] init ];
124
- [contentController setData: self .jsonString];
125
- [contentController setTemplateCaption: notification.request.content.title];
126
- [contentController setTemplateSubcaption: notification.request.content.body];
127
- if (content[kDeeplinkURL ] != nil ) {
128
- [contentController setDeeplinkURL: content[kDeeplinkURL ]];
129
- }
130
- [self addChildViewController: contentController];
131
- contentController.view .frame = self.view .frame ;
132
- [self .view addSubview: contentController.view];
133
- self.contentViewController = contentController;
103
+ [self setupContentController: contentController];
104
+ }
105
+ break ;
106
+ case CTNotificationContentTypeZeroBezel: {
107
+ CTZeroBezelController *contentController = [[CTZeroBezelController alloc ] init ];
108
+ [self setupContentController: contentController];
134
109
}
135
110
break ;
136
111
@@ -142,6 +117,19 @@ - (void)didReceiveNotification:(UNNotification *)notification {
142
117
self.preferredContentSize = self.contentViewController .preferredContentSize ;
143
118
}
144
119
120
+ - (void )setupContentController : (id )contentController {
121
+ [contentController setData: self .jsonString];
122
+ [contentController setTemplateCaption: _notification.request.content.title];
123
+ [contentController setTemplateSubcaption: _notification.request.content.body];
124
+ if (self.content [kDeeplinkURL ] != nil ) {
125
+ [contentController setDeeplinkURL: self .content[kDeeplinkURL ]];
126
+ }
127
+ [self addChildViewController: contentController];
128
+ [contentController view ].frame = self.view .frame ;
129
+ [self .view addSubview: [contentController view ]];
130
+ self.contentViewController = contentController;
131
+ }
132
+
145
133
- (void )updateContentType : (NSDictionary *)content {
146
134
if (content[kContentSlider ] != nil ) {
147
135
self.contentType = CTNotificationContentTypeContentSlider;
@@ -161,6 +149,8 @@ - (void)updateContentType:(NSDictionary *)content {
161
149
self.contentType = CTNotificationContentTypeManualCarousel;
162
150
} else if ([content[kTemplateId ] isEqualToString: kTemplateTimer ]) {
163
151
self.contentType = CTNotificationContentTypeTimerTemplate;
152
+ }else if ([content[kTemplateId ] isEqualToString: kTemplateZeroBezel ]) {
153
+ self.contentType = CTNotificationContentTypeZeroBezel;
164
154
} else {
165
155
// Invalid pt_id value fallback to basic.
166
156
self.contentType = CTNotificationContentTypeBasicTemplate;
0 commit comments