Skip to content

Commit

Permalink
Merge pull request #36 from CleverTap/develop
Browse files Browse the repository at this point in the history
Release 0.2.5
  • Loading branch information
nishant-clevertap authored Oct 23, 2023
2 parents 0d0b103 + 94d632a commit 4f2a8eb
Show file tree
Hide file tree
Showing 53 changed files with 31,724 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Change Log
==========
Version 0.2.5 (23 October, 2023)
-----------------------------------------------
- Fixes push notifications not being removed from notification center when clicked on expanded view.
- Fixes carousel not shown correctly for the first time when app is installed.

Version 0.2.4 (17 January, 2023)
-----------------------------------------------
- Adds support for importing from static libraries and frameworks.
Expand Down
2 changes: 1 addition & 1 deletion CTNotificationContent.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CTNotificationContent"
s.version = "0.2.4"
s.version = "0.2.5"
s.summary = "A Notification Content Extension class to display custom content interfaces for iOS 10 push notifications"
s.homepage = "https://github.com/CleverTap/CTNotificationContent"
s.license = "MIT"
Expand Down
15 changes: 15 additions & 0 deletions CTNotificationContent/CTNotificationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ - (void)openUrl:(NSURL *)url {
// Fallback on earlier versions
}
}

// This removes the clicked notification from Notification Center when clicked in expanded view.
UNUserNotificationCenter *current = [UNUserNotificationCenter currentNotificationCenter];
[current getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotification *> * _Nonnull notifications) {
NSString *notificationIdentifier;
for (NSUInteger i = 0; i < [notifications count]; i++) {
if ([notifications[i].request.identifier isEqualToString:self.notification.request.identifier]) {
notificationIdentifier = self.notification.request.identifier;
break;
}
}
if (notificationIdentifier) {
[[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers:@[notificationIdentifier]];
}
}];
}];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,24 @@ import UserNotificationsUI
if let url = jsonContent.pt_img3, !url.isEmpty {
imageUrls.append(url)
}

for (index,url) in imageUrls.enumerated() {

let dispatchGroup = DispatchGroup()
for (_,url) in imageUrls.enumerated() {
dispatchGroup.enter()
CTUtiltiy.checkImageUrlValid(imageUrl: url) { [weak self] (imageData) in
DispatchQueue.main.async {
if imageData != nil {
let itemComponents = CaptionedImageViewComponents(caption: self!.templateCaption, subcaption: self!.templateSubcaption, imageUrl: url, actionUrl: actionUrl, bgColor: self!.bgColor, captionColor: self!.captionColor, subcaptionColor: self!.subcaptionColor)
let itemView = CTCaptionedImageView(components: itemComponents)
self?.itemViews.append(itemView)
}
if index == imageUrls.count - 1 {
self?.setUpConstraints()
}
dispatchGroup.leave()
}
}
}
dispatchGroup.notify(queue: .main) {
self.setUpConstraints()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ fileprivate enum Constants {
autoDismiss = jsonContent.autoDismiss
showPaging = jsonContent.showsPaging
autoPlay = jsonContent.autoPlay

for (index,item) in jsonContent.items.enumerated() {

let dispatchGroup = DispatchGroup()
for (_,item) in jsonContent.items.enumerated() {
dispatchGroup.enter()
CTUtiltiy.checkImageUrlValid(imageUrl: item.imageUrl) { [weak self] (imageData) in
DispatchQueue.main.async {
if imageData != nil {
Expand All @@ -71,12 +73,13 @@ fileprivate enum Constants {
let keyItem = [Constants.kCaption : item.caption, Constants.kSubcaption : item.subcaption, Constants.kImageUrl : item.imageUrl, Constants.kActionUrl : item.actionUrl]
self?.items.append(keyItem)
}
if index == jsonContent.items.count - 1 {
self?.setUpConstraints()
}
dispatchGroup.leave()
}
}
}
dispatchGroup.notify(queue: .main) {
self.setUpConstraints()
}
}

func setUpConstraints() {
Expand Down
10 changes: 6 additions & 4 deletions Framework/CTNotificationContent.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>CTNotificationContent.framework/CTNotificationContent</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_i386_x86_64-simulator</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>CTNotificationContent.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>i386</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
Expand All @@ -21,14 +22,15 @@
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>CTNotificationContent.framework/CTNotificationContent</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_armv7</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>CTNotificationContent.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>armv7</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
#import <UserNotificationsUI/UserNotificationsUI.h>
#import "CTNotificationViewController.h"

@interface BaseCTNotificationContentViewController : UIViewController

- (UNNotificationContentExtensionResponseOption)handleAction:(NSString *)action; // must override in subclass

- (NSString *)getDeeplinkUrl; // must override in subclass

- (CTNotificationViewController *)getParentViewController;

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;

@end
Loading

0 comments on commit 4f2a8eb

Please sign in to comment.