Skip to content

Commit

Permalink
Merge pull request #429 from Kommunicate-io/release/7.1.9
Browse files Browse the repository at this point in the history
Release/7.1.9
  • Loading branch information
AbhijeetRanjan308 authored May 27, 2024
2 parents 0f14c48 + d2fb92a commit d6ea131
Show file tree
Hide file tree
Showing 19 changed files with 652 additions and 45 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# CHANGELOG

The changelog for [Kommunicate-iOS-SDK](https://github.com/Kommunicate-io/Kommunicate-iOS-SDK). Also see the [releases](https://github.com/Kommunicate-io/Kommunicate-iOS-SDK/releases) on Github.
## [7.1.9] 2024-05-27
- Added Privacy Manifest File.
- Fixed color difference in Attachment Icon.
- Added Five Star CSAT Ratting.
- Exposed Funtion to show or hide Attachment Options.
- Updated Check Box UI for Form.
- Updated Time and Date Format.(Similar to Android & Web)

## [7.1.8] 2024-04-23
- Added Support for EU region.
- Updated the default color for send message text to white.
Expand Down
26 changes: 13 additions & 13 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ PODS:
- iOSSnapshotTestCase/SwiftSupport (8.0.0):
- iOSSnapshotTestCase/Core
- Kingfisher (7.6.2)
- Kommunicate (7.1.8):
- KommunicateChatUI-iOS-SDK (~> 1.3.2)
- KommunicateChatUI-iOS-SDK (1.3.2):
- KommunicateChatUI-iOS-SDK/Complete (= 1.3.2)
- KommunicateChatUI-iOS-SDK/Complete (1.3.2):
- Kommunicate (7.1.9):
- KommunicateChatUI-iOS-SDK (= 1.3.3)
- KommunicateChatUI-iOS-SDK (1.3.3):
- KommunicateChatUI-iOS-SDK/Complete (= 1.3.3)
- KommunicateChatUI-iOS-SDK/Complete (1.3.3):
- iOSDropDown
- Kingfisher (~> 7.6.2)
- KommunicateChatUI-iOS-SDK/RichMessageKit
- KommunicateCore-iOS-SDK (~> 1.2.0)
- KommunicateCore-iOS-SDK (= 1.2.1)
- SwipeCellKit (~> 2.7.1)
- ZendeskChatProvidersSDK (~> 3.0.0)
- KommunicateChatUI-iOS-SDK/RichMessageKit (1.3.2)
- KommunicateCore-iOS-SDK (1.2.0)
- KommunicateChatUI-iOS-SDK/RichMessageKit (1.3.3)
- KommunicateCore-iOS-SDK (1.2.1)
- Nimble (13.3.0):
- CwlPreconditionTesting (~> 2.2.0)
- Nimble-Snapshots (9.7.0):
- Nimble-Snapshots/Core (= 9.7.0)
- Nimble-Snapshots/Core (9.7.0):
- iOSSnapshotTestCase (~> 8.0)
- Nimble (~> 13.0)
- Quick (7.5.0)
- Quick (7.6.0)
- SwipeCellKit (2.7.1)
- ZendeskChatProvidersSDK (3.0.0)

Expand Down Expand Up @@ -77,12 +77,12 @@ SPEC CHECKSUMS:
iOSDropDown: ce9daa584eaa5567cafc1b633e3cc7eb6d9cea42
iOSSnapshotTestCase: a670511f9ee3829c2b9c23e6e68f315fd7b6790f
Kingfisher: 6c5449c6450c5239166510ba04afe374a98afc4f
Kommunicate: 32f3bb8766955e9153370ef8500c98f78f777e16
KommunicateChatUI-iOS-SDK: 41b9975a2f3da9a0cda367550ef7038e46425d31
KommunicateCore-iOS-SDK: 5ba7ae15243532039792f3e166d3750a07cf8700
Kommunicate: 7f3bd576c238ba492199de7ec3b119fa0cfa678d
KommunicateChatUI-iOS-SDK: c8cdd4c97266a21ce675144eb5b45bfa060cd2e6
KommunicateCore-iOS-SDK: 445c510bd901ca60e4aa8193beb46cfc7aeb2f27
Nimble: 3ac6c6b0b7e9835d1540b6507d8054b12a415536
Nimble-Snapshots: 7f2710c507469eb0fc4912f45d0f280e15f91966
Quick: 2b651168441479b949ba987f3cee41a9cc53aa32
Quick: a65742a544182cb9ecb231e1e71bcb87f4d12ce3
SwipeCellKit: 3972254a826da74609926daf59b08d6c72e619ea
ZendeskChatProvidersSDK: af93e02e2058875f92e6ad86e74ee51203b4079e

Expand Down
4 changes: 2 additions & 2 deletions Kommunicate.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Kommunicate'
s.version = '7.1.8'
s.version = '7.1.9'
s.summary = 'Kommunicate iOS SDK for customer support.'
s.homepage = 'https://github.com/Kommunicate-io/Kommunicate-iOS-SDK'
s.license = { :type => 'BSD-3-Clause', :file => 'LICENSE' }
Expand All @@ -10,5 +10,5 @@ Pod::Spec.new do |s|
s.swift_version = '5.0'
s.source_files = 'Sources/Kommunicate/Classes/**/*.{swift}'
s.resources = 'Sources/Resources/**/*{lproj,storyboard,xib,xcassets,json,strings}'
s.dependency 'KommunicateChatUI-iOS-SDK' , '~> 1.3.2'
s.dependency 'KommunicateChatUI-iOS-SDK' , '1.3.3'
end
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
"repositoryURL": "https://github.com/Kommunicate-io/KommunicateChatUI-iOS-SDK.git",
"state": {
"branch": null,
"revision": "2dfd4d83a1a303be9a6b9a3de82268ae71b5ab54",
"version": "1.3.2"
"revision": "d2c51174087710f9f3d3550d90fcfeeac84041c8",
"version": "1.3.3"
}
},
{
"package": "KommunicateCore_iOS_SDK",
"repositoryURL": "https://github.com/Kommunicate-io/KommunicateCore-iOS-SDK.git",
"state": {
"branch": null,
"revision": "1f49f42f23c8d85b2d0b800755d8df7ad7283136",
"version": "1.2.0"
"revision": "d8f3e1d62497b8df12d703bf2353bf7f795c5565",
"version": "1.2.1"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
),
],
dependencies: [
.package(name: "KommunicateChatUI-iOS-SDK", url: "https://github.com/Kommunicate-io/KommunicateChatUI-iOS-SDK.git", from: "1.3.2"),
.package(name: "KommunicateChatUI-iOS-SDK", url: "https://github.com/Kommunicate-io/KommunicateChatUI-iOS-SDK.git", from: "1.3.3"),
],
targets: [
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,55 @@ extension KMConversationService {
}
}
}

func submitFiveStarFeedback(
groupId: Int,
feedback: KMFeedback,
userId: String,
userName: String,
assigneeId: String,
applicationId: String,
completion: @escaping (Result<ConversationFeedback, FeedbackError>) -> Void
) {
guard let url = URLBuilder.feedbackURLForSubmission().url else {
completion(.failure(.api(.urlBuilding)))
return
}
let userInfo: [String: Any] = [
FeedbackParamKey.userName: userName,
FeedbackParamKey.userId: userId,
]
var params: [String: Any] = [
FeedbackParamKey.groupId: groupId,
FeedbackParamKey.rating: feedback.rating,
FeedbackParamKey.applicationId: applicationId,
FeedbackParamKey.assigneeId: assigneeId,
FeedbackParamKey.userInfo: userInfo,
]
if let comment = feedback.comment, !comment.isEmpty {
params[FeedbackParamKey.comment] = [comment]
}
DataLoader.postRequest(url: url, params: params) { result in
switch result {
case let .success(data):
guard let feedbackResponse =
try? ConversationFeedbackSubmissionResponse(data: data)
else {
completion(.failure(.api(.jsonConversion)))
return
}
do {
let feedback = try feedbackResponse.conversationFeedback()
completion(.success(feedback))
} catch let error as FeedbackError {
completion(.failure(error))
} catch {
completion(.failure(.notFound))
}
case let .failure(error):
completion(.failure(.api(.network(error))))
}
}
}

}
1 change: 1 addition & 0 deletions Sources/Kommunicate/Classes/KMAppSettingsResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct ChatWidgetResponse: Decodable {
let zendeskChatSdkKey: String?
let defaultUploadOverride : DefaultUploadOverride?
let pseudonymsEnabled : Bool?
let csatRatingBase : Int?
let disableChatWidget : Bool?
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/Kommunicate/Classes/KMAppSettingsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class KMAppSettingService {
}

KMAppUserDefaultHandler.shared.botMessageDelayInterval = chatWidget.botMessageDelayInterval ?? 0
KMAppUserDefaultHandler.shared.csatRatingBase = chatWidget.csatRatingBase ?? 3

guard let primaryColor = chatWidget.primaryColor else {
setupDefaultSettings()
Expand All @@ -71,6 +72,7 @@ class KMAppSettingService {
appSettings.hidePostCTAEnabled = chatWidget.hidePostCTA ?? false
appSettings.defaultUploadOverrideUrl = chatWidget.defaultUploadOverride?.url ?? ""
appSettings.defaultUploadOverrideHeaders = chatWidget.defaultUploadOverride?.headers ?? [:]
appSettings.csatRatingBase = chatWidget.csatRatingBase ?? 3
appSettingsUserDefaults.updateOrSetAppSettings(appSettings: appSettings)
}

Expand Down
9 changes: 9 additions & 0 deletions Sources/Kommunicate/Classes/KMAppUserDefaultHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ class KMAppUserDefaultHandler: NSObject {
return userDefaultSuite.integer(forKey: Key.BotMessageDelayInterval)
}
}
var csatRatingBase: Int {
set {
userDefaultSuite.set(newValue, forKey: Key.CSATRatingBase)
}
get {
return userDefaultSuite.integer(forKey: Key.CSATRatingBase)
}
}

private let userDefaultSuite: UserDefaults

Expand All @@ -54,5 +62,6 @@ private extension KMAppUserDefaultHandler {
enum Key {
static let CSATEnabled = "CSAT_ENABLED"
static let BotMessageDelayInterval = "BOT_MESSAGE_DELAY_INTERVAL"
static let CSATRatingBase = "CSAT_RATTING_BASE"
}
}
102 changes: 80 additions & 22 deletions Sources/Kommunicate/Classes/KMConversationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
private let faqIdentifier = 11_223_346
private let kmConversationViewConfiguration: KMConversationViewConfiguration
private weak var ratingVC: RatingViewController?
private weak var fiveStarRatingVC: KMStarRattingViewController?
private let registerUserClientService = ALRegisterUserClientService()
let kmBotService = KMBotService()
private var assigneeUserId: String?
Expand Down Expand Up @@ -718,34 +719,65 @@ extension KMConversationViewController {
}

private func showRatingView() {
guard let currentViewController = UIViewController.topViewController(), currentViewController is KMConversationViewController, self.ratingVC == nil else { return }
guard let currentViewController = UIViewController.topViewController(), currentViewController is KMConversationViewController else { return }

let ratingVC = RatingViewController()
ratingVC.closeButtontapped = { [weak self] in
self?.hideRatingView()
}
ratingVC.feedbackSubmitted = { [weak self] feedback in
print("feedback submitted with rating: \(feedback.rating)")
KMCustomEventHandler.shared.publish(triggeredEvent: KMCustomEvent.submitRatingClick, data: ["rating": feedback.rating.rawValue,"comment":feedback.comment ?? "","conversationId": self?.viewModel.channelKey])
self?.hideRatingView()
self?.submitFeedback(feedback: feedback)
}
if KMAppUserDefaultHandler.shared.csatRatingBase == 5 {
guard self.fiveStarRatingVC == nil else { return }
let ratingVC = KMStarRattingViewController()
ratingVC.closeButtontapped = { [weak self] in
self?.hideRatingView()
}
ratingVC.feedbackSubmitted = { [weak self] feedback in
print("feedback submitted with rating: \(feedback.rating)")
KMCustomEventHandler.shared.publish(triggeredEvent: KMCustomEvent.submitRatingClick, data: ["rating": feedback.rating,"comment":feedback.comment ?? "","conversationId": self?.viewModel.channelKey])
self?.hideRatingView()
self?.submitFiveStarFeedback(feedback: feedback)
}

present(ratingVC, animated: true, completion: { [weak self] in
self?.ratingVC = ratingVC
})
present(ratingVC, animated: true, completion: { [weak self] in
self?.fiveStarRatingVC = ratingVC
})
} else {
guard self.ratingVC == nil else { return }
let ratingVC = RatingViewController()
ratingVC.closeButtontapped = { [weak self] in
self?.hideRatingView()
}
ratingVC.feedbackSubmitted = { [weak self] feedback in
print("feedback submitted with rating: \(feedback.rating)")
KMCustomEventHandler.shared.publish(triggeredEvent: KMCustomEvent.submitRatingClick, data: ["rating": feedback.rating.rawValue,"comment":feedback.comment ?? "","conversationId": self?.viewModel.channelKey])
self?.hideRatingView()
self?.submitFeedback(feedback: feedback)
}

present(ratingVC, animated: true, completion: { [weak self] in
self?.ratingVC = ratingVC
})
}
}

private func hideRatingView() {
guard let ratingVC = ratingVC,
UIViewController.topViewController() is RatingViewController,
!ratingVC.isBeingDismissed
else {
return
if KMAppUserDefaultHandler.shared.csatRatingBase == 5 {
guard let ratingVC = fiveStarRatingVC,
UIViewController.topViewController() is KMStarRattingViewController,
!ratingVC.isBeingDismissed
else {
return
}
dismiss(animated: true, completion: { [weak self] in
self?.fiveStarRatingVC = nil
})
} else {
guard let ratingVC = ratingVC,
UIViewController.topViewController() is RatingViewController,
!ratingVC.isBeingDismissed
else {
return
}
dismiss(animated: true, completion: { [weak self] in
self?.ratingVC = nil
})
}
dismiss(animated: true, completion: { [weak self] in
self?.ratingVC = nil
})
}

private func submitFeedback(feedback: Feedback) {
Expand All @@ -770,6 +802,29 @@ extension KMConversationViewController {
}
}
}

private func submitFiveStarFeedback(feedback: KMFeedback) {
guard let channelId = viewModel.channelKey else { return }
conversationService.submitFiveStarFeedback(
groupId: channelId.intValue,
feedback: feedback,
userId: KMUserDefaultHandler.getUserId(),
userName: KMUserDefaultHandler.getDisplayName() ?? "",
assigneeId: assigneeUserId ?? "",
applicationId: KMUserDefaultHandler.getApplicationKey()
) { [weak self] result in
switch result {
case let .success(conversationFeedback):
print("feedback submit response success: \(conversationFeedback)")
guard conversationFeedback.feedback != nil else { return }
DispatchQueue.main.async {
self?.showFiveStar(feedback: feedback)
}
case let .failure(error):
print("feedback submit response failure: \(error)")
}
}
}

private func updateMessageListBottomPadding(isClosedViewHidden: Bool) {
var heightDiff: Double = 0
Expand Down Expand Up @@ -803,6 +858,9 @@ extension KMConversationViewController {
private func show(feedback: Feedback) {
updateMessageListBottomPadding(isClosedViewHidden: false)
}
private func showFiveStar(feedback: KMFeedback) {
updateMessageListBottomPadding(isClosedViewHidden: false)
}
}

extension KMConversationViewController {
Expand Down
Loading

0 comments on commit d6ea131

Please sign in to comment.