Skip to content

Commit b43ab5f

Browse files
Merge pull request #16 from CleverTap/SDK-1794_ZeroBezelTemplateP
origin/SDK-1794_ZeroBezelTemplateP
2 parents 91d9cfb + 71f47e8 commit b43ab5f

File tree

44 files changed

+969
-467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+969
-467
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Change Log
22
==========
33

4+
Version 0.2.1 (30 August, 2022)
5+
-----------------------------------------------
6+
- Supports a new template - Zero Bezel
7+
48
Version 0.2.0 *(24 June, 2022)*
59
-----------------------------------------------
610
- Supports new templates - Basic, Auto carousel, Manual carousel and Timer
@@ -32,4 +36,4 @@ Version 0.1.1 *(23 July, 2017)*
3236

3337
Version 0.1.0 *(8 March, 2017)*
3438
-------------------------------------------
35-
- Initial release.
39+
- Initial release.

CTNotificationContent.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "CTNotificationContent"
3-
s.version = "0.2.0"
3+
s.version = "0.2.1"
44
s.summary = "A Notification Content Extension class to display custom content interfaces for iOS 10 push notifications"
55
s.homepage = "https://github.com/CleverTap/CTNotificationContent"
66
s.license = "MIT"

CTNotificationContent.xcodeproj/project.pbxproj

Lines changed: 172 additions & 36 deletions
Large diffs are not rendered by default.

CTNotificationContent/CTNotificationViewController.m

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ typedef NS_ENUM(NSInteger, CTNotificationContentType) {
1111
CTNotificationContentTypeAutoCarousel = 3,
1212
CTNotificationContentTypeManualCarousel = 4,
1313
CTNotificationContentTypeTimerTemplate = 5,
14+
CTNotificationContentTypeZeroBezel = 6
1415
};
1516

1617
static NSString * const kTemplateId = @"pt_id";
@@ -23,12 +24,15 @@ typedef NS_ENUM(NSInteger, CTNotificationContentType) {
2324
static NSString * const kSingleMediaURL = @"ct_mediaUrl";
2425
static NSString * const kJSON = @"pt_json";
2526
static NSString * const kDeeplinkURL = @"wzrk_dl";
27+
static NSString * const kTemplateZeroBezel = @"pt_zero_bezel";
2628

2729
@interface CTNotificationViewController () <UNNotificationContentExtension>
2830

2931
@property(nonatomic, assign) CTNotificationContentType contentType;
3032
@property(nonatomic, strong, readwrite) BaseCTNotificationContentViewController *contentViewController;
3133
@property(nonatomic) NSString *jsonString;
34+
@property(nonatomic) NSDictionary *content;
35+
@property(nonatomic) UNNotification *notification;
3236

3337
@end
3438

@@ -41,17 +45,19 @@ - (void)viewDidLoad {
4145
}
4246

4347
- (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];
4652

4753
switch (self.contentType) {
4854
case CTNotificationContentTypeContentSlider: {
4955
CTContentSliderController *contentController = [[CTContentSliderController alloc] init];
50-
[contentController setData:content[kContentSlider]];
56+
[contentController setData:_content[kContentSlider]];
5157
[contentController setTemplateCaption:notification.request.content.title];
5258
[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]];
5561
}
5662
[self addChildViewController:contentController];
5763
contentController.view.frame = self.view.frame;
@@ -63,10 +69,10 @@ - (void)didReceiveNotification:(UNNotification *)notification {
6369
CTSingleMediaController *contentController = [[CTSingleMediaController alloc] init];
6470
[contentController setCaption:notification.request.content.title];
6571
[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]];
7076
}
7177
[self addChildViewController:contentController];
7278
contentController.view.frame = self.view.frame;
@@ -76,61 +82,30 @@ - (void)didReceiveNotification:(UNNotification *)notification {
7682
break;
7783
case CTNotificationContentTypeBasicTemplate: {
7884
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-
}
8585
[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];
9087
}
9188
break;
9289
case CTNotificationContentTypeAutoCarousel: {
9390
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-
}
10091
[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];
10593
}
10694
break;
10795
case CTNotificationContentTypeManualCarousel: {
10896
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-
}
11597
[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];
12099
}
121100
break;
122101
case CTNotificationContentTypeTimerTemplate: {
123102
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];
134109
}
135110
break;
136111

@@ -142,6 +117,19 @@ - (void)didReceiveNotification:(UNNotification *)notification {
142117
self.preferredContentSize = self.contentViewController.preferredContentSize;
143118
}
144119

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+
145133
- (void)updateContentType:(NSDictionary *)content {
146134
if (content[kContentSlider] != nil) {
147135
self.contentType = CTNotificationContentTypeContentSlider;
@@ -161,6 +149,8 @@ - (void)updateContentType:(NSDictionary *)content {
161149
self.contentType = CTNotificationContentTypeManualCarousel;
162150
} else if ([content[kTemplateId] isEqualToString:kTemplateTimer]) {
163151
self.contentType = CTNotificationContentTypeTimerTemplate;
152+
}else if ([content[kTemplateId] isEqualToString:kTemplateZeroBezel]) {
153+
self.contentType = CTNotificationContentTypeZeroBezel;
164154
} else {
165155
// Invalid pt_id value fallback to basic.
166156
self.contentType = CTNotificationContentTypeBasicTemplate;

CTNotificationContent/Controllers/Assets.xcassets/AccentColor.colorset/Contents.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

CTNotificationContent/Controllers/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 0 additions & 98 deletions
This file was deleted.

CTNotificationContent/Controllers/Assets.xcassets/Contents.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

CTNotificationContent/Controllers/CTCarouselController.swift renamed to CTNotificationContent/Templates/Carousel/Controller/CTCarouselController.swift

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
import UIKit
22
import UserNotificationsUI
33

4-
struct CarouselProperties: Decodable {
5-
let pt_title: String?
6-
let pt_msg: String?
7-
let pt_msg_summary: String?
8-
let pt_dl1: String?
9-
let pt_big_img: String?
10-
let pt_img1: String?
11-
let pt_img2: String?
12-
let pt_img3: String?
13-
let pt_bg: String?
14-
let pt_title_clr: String?
15-
let pt_msg_clr: String?
16-
}
17-
184
@objc public class CTCarouselController: BaseCTNotificationContentViewController {
195
var contentView: UIView = UIView(frame: .zero)
206
var pageControl: UIPageControl = UIPageControl(frame: .zero)
@@ -42,21 +28,10 @@ struct CarouselProperties: Decodable {
4228
contentView = UIView(frame: view.frame)
4329
view.addSubview(contentView)
4430

45-
loadContentData()
31+
jsonContent = CTUtiltiy.loadContentData(data: data)
4632
createView()
4733
}
4834

49-
func loadContentData() {
50-
if let configData = data.data(using: .utf8) {
51-
do {
52-
jsonContent = try JSONDecoder().decode(CarouselProperties.self, from: configData)
53-
} catch let error {
54-
print("Failed to load: \(error.localizedDescription)")
55-
jsonContent = nil
56-
}
57-
}
58-
}
59-
6035
func createView() {
6136
guard let jsonContent = jsonContent else {
6237
// Show default alert view and update constraints when json data is not available.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// CarouselProperties.swift
3+
// CleverTap-iOS-SDK
4+
//
5+
// Created by Aishwarya Nanna on 26/08/22.
6+
//
7+
8+
import Foundation
9+
10+
struct CarouselProperties: Decodable {
11+
let pt_title: String?
12+
let pt_msg: String?
13+
let pt_msg_summary: String?
14+
let pt_dl1: String?
15+
let pt_big_img: String?
16+
let pt_img1: String?
17+
let pt_img2: String?
18+
let pt_img3: String?
19+
let pt_bg: String?
20+
let pt_title_clr: String?
21+
let pt_msg_clr: String?
22+
}

0 commit comments

Comments
 (0)