Skip to content

Commit 76359dc

Browse files
Merge pull request #463 from Kommunicate-io/dev
Release/7.2.5
2 parents 178e852 + 043562d commit 76359dc

File tree

10 files changed

+347
-27
lines changed

10 files changed

+347
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
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.
44

5+
## [7.2.5] 2024-12-24
6+
- Fixed typo of registerUserAsVistor with registerUserAsVisitor.
7+
- SSL pinning enable disable configuration added.
8+
- Fixed the issue where video thumbnails were not displaying correctly.
9+
510
## [7.2.4] 2024-12-03
611
- Fixed Away Message not showing in Bot Delay.
712
- Fixed an issue where captions were cut off in Video Rich Messages.

Example/Kommunicate/LoginViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
setupApplicationKey(applicationId)
9696
let kmUser = userWithUserId(Kommunicate.randomId(), andApplicationId: applicationId)
9797
activityIndicator.startAnimating()
98-
Kommunicate.registerUserAsVistor(kmUser, completion: {
98+
Kommunicate.registerUserAsVisitor(kmUser, completion: {
9999
response, error in
100100
self.activityIndicator.stopAnimating()
101101
guard error == nil else {

Example/Podfile.lock

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ PODS:
1515
- iOSSnapshotTestCase/SwiftSupport (8.0.0):
1616
- iOSSnapshotTestCase/Core
1717
- Kingfisher (7.6.2)
18-
- Kommunicate (7.2.4):
19-
- KommunicateChatUI-iOS-SDK (= 1.3.8)
20-
- KommunicateChatUI-iOS-SDK (1.3.8):
21-
- KommunicateChatUI-iOS-SDK/Complete (= 1.3.8)
22-
- KommunicateChatUI-iOS-SDK/Complete (1.3.8):
18+
- Kommunicate (7.2.5):
19+
- KommunicateChatUI-iOS-SDK (= 1.3.9)
20+
- KommunicateChatUI-iOS-SDK (1.3.9):
21+
- KommunicateChatUI-iOS-SDK/Complete (= 1.3.9)
22+
- KommunicateChatUI-iOS-SDK/Complete (1.3.9):
2323
- iOSDropDown
2424
- Kingfisher (~> 7.6.2)
2525
- KommunicateChatUI-iOS-SDK/RichMessageKit
26-
- KommunicateCore-iOS-SDK (= 1.2.4)
26+
- KommunicateCore-iOS-SDK (= 1.2.5)
2727
- SwipeCellKit (~> 2.7.1)
28-
- KommunicateChatUI-iOS-SDK/RichMessageKit (1.3.8)
29-
- KommunicateCore-iOS-SDK (1.2.4)
30-
- Nimble (13.6.2):
28+
- KommunicateChatUI-iOS-SDK/RichMessageKit (1.3.9)
29+
- KommunicateCore-iOS-SDK (1.2.5)
30+
- Nimble (13.7.1):
3131
- CwlPreconditionTesting (~> 2.2.0)
3232
- Nimble-Snapshots (9.8.0):
3333
- Nimble-Snapshots/Core (= 9.8.0)
@@ -74,10 +74,10 @@ SPEC CHECKSUMS:
7474
iOSDropDown: ce9daa584eaa5567cafc1b633e3cc7eb6d9cea42
7575
iOSSnapshotTestCase: a670511f9ee3829c2b9c23e6e68f315fd7b6790f
7676
Kingfisher: 6c5449c6450c5239166510ba04afe374a98afc4f
77-
Kommunicate: 3d18f7229fbf1ff7e16a027cbc5e3d6fe3316f30
78-
KommunicateChatUI-iOS-SDK: 4ca12728c40d134b330f1e8ac5335e1b98ca6552
79-
KommunicateCore-iOS-SDK: 2adcd775f5ed6fdcdbcac47986144c177fc44ab0
80-
Nimble: 8cd9e713948ea6a61980e82d2bec937acec16b91
77+
Kommunicate: c886c6b4cdd32d4976eab22968ab1f05e0a9f08e
78+
KommunicateChatUI-iOS-SDK: 53efa89eaab6e8af7a7dbd9f34e106ac6171c279
79+
KommunicateCore-iOS-SDK: 5dc0d852f3e49c37b33a808d73556cf683b2f6c0
80+
Nimble: 317d713c30c3336dd8571da1889f7ec3afc626e8
8181
Nimble-Snapshots: 240ea76ee8e52dfc1387b8d0d9bf1db3420cabbd
8282
Quick: b8bec97cd4b9f21da0472d45580f763b801fc353
8383
SwipeCellKit: 3972254a826da74609926daf59b08d6c72e619ea

Example/Tests/KommunicateTests.swift

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class KommunicateTests: XCTestCase {
88
static var showConversationsCalled = false
99
static var createConversationsCalled = false
1010
static var loggedIn = true
11+
static var conversationID: String?
1112

1213
override class var isLoggedIn: Bool {
1314
return loggedIn
@@ -130,7 +131,206 @@ class KommunicateTests: XCTestCase {
130131
expectation.fulfill()
131132
}
132133
}
134+
135+
func testCreateAndLaunchConversationWithCustomData() {
136+
KommunicateMock.applozicClientType = ApplozicClientMock.self
137+
let expectation = self.expectation(description: "Completion handler called")
138+
139+
let kmConversation = KMConversationBuilder()
140+
.useLastConversation(false)
141+
.setPreFilledMessage("This is a sample prefilled message.")
142+
.withMetaData(["TestMetadata": "SampleValue"])
143+
.withConversationTitle("Automation Conversation")
144+
.build()
145+
146+
if KommunicateMock.isLoggedIn {
147+
launchConversation(kmConversation, expectation: expectation)
148+
} else {
149+
KommunicateMock.registerUserAsVistor { response, error in
150+
if let error = error {
151+
XCTFail("User registration failed: \(error.localizedDescription)")
152+
expectation.fulfill()
153+
return
154+
}
155+
KommunicateMock.loggedIn = true
156+
self.launchConversation(kmConversation, expectation: expectation)
157+
}
158+
}
159+
waitForExpectations(timeout: 30)
160+
}
161+
162+
private var testWindow: UIWindow? // Property to retain UIWindow during the test lifecycle
163+
164+
private func launchConversation(_ conversation: KMConversation, expectation: XCTestExpectation) {
165+
// Retain the UIWindow to prevent deallocation
166+
let dummyViewController = UIViewController()
167+
testWindow = UIWindow(frame: UIScreen.main.bounds)
168+
testWindow?.rootViewController = dummyViewController
169+
testWindow?.makeKeyAndVisible()
170+
171+
// Launch the conversation
172+
KommunicateMock.launchConversation(conversation: conversation, viewController: dummyViewController) { result in
173+
switch result {
174+
case .success(let conversationId):
175+
print("Conversation id:", conversationId)
176+
XCTAssertTrue(true, "Conversation created successfully.")
177+
case .failure(let kmConversationError):
178+
XCTAssertNotNil(kmConversationError, "Conversation creation failed")
179+
XCTFail("Failed to create conversation.")
180+
}
181+
expectation.fulfill()
182+
}
183+
}
184+
185+
func testUpdateConversationAssignee() {
186+
KommunicateMock.applozicClientType = ApplozicClientMock.self
187+
let expectation = self.expectation(description: "Completion handler called")
188+
let assigneeId = "alex-nwqih"
189+
190+
// Helper function to handle conversation update
191+
func updateConversation(with conversationId: String) {
192+
let conversation = KMConversationBuilder()
193+
.withClientConversationId(conversationId)
194+
.withConversationAssignee(assigneeId)
195+
.build()
196+
197+
KommunicateMock.updateConversation(conversation: conversation) { response in
198+
switch response {
199+
case .success:
200+
XCTAssertTrue(true, "Conversation is updated successfully")
201+
case .failure:
202+
XCTFail("Failed to update conversation")
203+
}
204+
expectation.fulfill()
205+
}
206+
}
207+
208+
if let conversationId = KommunicateMock.conversationID {
209+
// If conversationID exists, update conversation
210+
updateConversation(with: conversationId)
211+
} else {
212+
// Otherwise, create a new conversation and update
213+
let kmConversation = KMConversationBuilder()
214+
.useLastConversation(false)
215+
.withMetaData(["TestMetadata": "SampleValue"])
216+
.withConversationTitle("Automation Conversation")
217+
.build()
218+
219+
KommunicateMock.createConversation(conversation: kmConversation) { [weak self] result in
220+
switch result {
221+
case .success(let conversationId):
222+
KommunicateMock.conversationID = conversationId
223+
KommunicateMock.loggedIn = true
224+
updateConversation(with: conversationId)
225+
case .failure(let error):
226+
XCTAssertNotNil(error, "Conversation creation failed")
227+
expectation.fulfill()
228+
}
229+
}
230+
}
231+
232+
waitForExpectations(timeout: 30)
233+
}
234+
235+
func testUpdateTeamID() {
236+
KommunicateMock.applozicClientType = ApplozicClientMock.self
237+
let expectation = self.expectation(description: "Completion handler called")
238+
let teamID = "107732724"
239+
240+
// Helper function to handle conversation update
241+
func updateConversation(with conversationId: String) {
242+
let conversation = KMConversationBuilder()
243+
.withClientConversationId(conversationId)
244+
.withTeamId(teamID)
245+
.build()
246+
247+
KommunicateMock.updateConversation(conversation: conversation) { response in
248+
switch response {
249+
case .success:
250+
XCTAssertTrue(true, "Conversation is updated successfully")
251+
case .failure:
252+
XCTFail("Failed to update conversation")
253+
}
254+
expectation.fulfill()
255+
}
256+
}
257+
258+
if let conversationId = KommunicateMock.conversationID {
259+
// If conversationID exists, update conversation
260+
updateConversation(with: conversationId)
261+
} else {
262+
// Otherwise, create a new conversation and update
263+
let kmConversation = KMConversationBuilder()
264+
.useLastConversation(false)
265+
.withMetaData(["TestMetadata": "SampleValue"])
266+
.withConversationTitle("Automation Conversation")
267+
.build()
268+
269+
KommunicateMock.createConversation(conversation: kmConversation) { [weak self] result in
270+
switch result {
271+
case .success(let conversationId):
272+
KommunicateMock.conversationID = conversationId
273+
KommunicateMock.loggedIn = true
274+
updateConversation(with: conversationId)
275+
case .failure(let error):
276+
XCTAssertNotNil(error, "Conversation creation failed")
277+
expectation.fulfill()
278+
}
279+
}
280+
}
281+
282+
waitForExpectations(timeout: 30)
283+
}
284+
285+
func testUpdateConversationMetadata() {
286+
KommunicateMock.applozicClientType = ApplozicClientMock.self
287+
let expectation = self.expectation(description: "Completion handler called")
288+
let metaData = ["name": "Alice", "city": "London", "hobby": "Painting"]
289+
290+
// Helper function to handle conversation update
291+
func updateConversation(with conversationId: String) {
292+
let conversation = KMConversationBuilder()
293+
.withClientConversationId(conversationId)
294+
.withMetaData(metaData)
295+
.build()
296+
297+
KommunicateMock.updateConversation(conversation: conversation) { response in
298+
switch response {
299+
case .success:
300+
XCTAssertTrue(true, "Conversation is updated successfully")
301+
case .failure:
302+
XCTFail("Failed to update conversation")
303+
}
304+
expectation.fulfill()
305+
}
306+
}
133307

308+
if let conversationId = KommunicateMock.conversationID {
309+
// If conversationID exists, update conversation
310+
updateConversation(with: conversationId)
311+
} else {
312+
// Otherwise, create a new conversation and update
313+
let kmConversation = KMConversationBuilder()
314+
.useLastConversation(false)
315+
.withMetaData(["TestMetadata": "SampleValue"])
316+
.withConversationTitle("Automation Conversation")
317+
.build()
318+
319+
KommunicateMock.createConversation(conversation: kmConversation) { [weak self] result in
320+
switch result {
321+
case .success(let conversationId):
322+
KommunicateMock.conversationID = conversationId
323+
updateConversation(with: conversationId)
324+
KommunicateMock.loggedIn = true
325+
case .failure(let error):
326+
XCTAssertNotNil(error, "Conversation creation failed")
327+
expectation.fulfill()
328+
}
329+
}
330+
}
331+
332+
waitForExpectations(timeout: 30)
333+
}
134334

135335
func testSendMessageFunction() {
136336
KommunicateMock.applozicClientType = ApplozicClientMock.self

Kommunicate.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Kommunicate'
3-
s.version = '7.2.4'
3+
s.version = '7.2.5'
44
s.summary = 'Kommunicate iOS SDK for customer support.'
55
s.homepage = 'https://github.com/Kommunicate-io/Kommunicate-iOS-SDK'
66
s.license = { :type => 'BSD-3-Clause', :file => 'LICENSE' }
@@ -10,5 +10,5 @@ Pod::Spec.new do |s|
1010
s.swift_version = '5.0'
1111
s.source_files = 'Sources/Kommunicate/Classes/**/*.{swift}'
1212
s.resources = 'Sources/Resources/**/*{lproj,storyboard,xib,xcassets,json,strings}'
13-
s.dependency 'KommunicateChatUI-iOS-SDK' , '1.3.8'
13+
s.dependency 'KommunicateChatUI-iOS-SDK' , '1.3.9'
1414
end

Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let package = Package(
1313
),
1414
],
1515
dependencies: [
16-
.package(name: "KommunicateChatUI-iOS-SDK", url: "https://github.com/Kommunicate-io/KommunicateChatUI-iOS-SDK.git", from: "1.3.8"),
16+
.package(name: "KommunicateChatUI-iOS-SDK", url: "https://github.com/Kommunicate-io/KommunicateChatUI-iOS-SDK.git", from: "1.3.9"),
1717
],
1818
targets: [
1919
.target(

Sources/Kommunicate/Classes/DataLoader.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ class DataLoader {
2323

2424
// set up the session
2525
let config = URLSessionConfiguration.default
26-
let session = URLSession(
27-
configuration: config,
28-
delegate: KMURLSessionPinningDelegate(),
29-
delegateQueue: nil
30-
)
26+
let session: URLSession = {
27+
if Kommunicate.isKMSSLPinningEnabled {
28+
return URLSession(configuration: config, delegate: KMURLSessionPinningDelegate(), delegateQueue: nil)
29+
} else {
30+
return URLSession(configuration: config)
31+
}
32+
}()
3133

3234
// make the request
3335
let task = session.dataTask(with: urlRequest) {

Sources/Kommunicate/Classes/KMConversation.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import KommunicateCore_iOS_SDK
2323
public var teamId: String?
2424
public var defaultConversationAssignee: String?
2525
public var appName: String? = Bundle.main.displayName
26+
public var prefilledMessage: String? = nil
2627

2728
public init(userId: String) {
2829
self.userId = userId
@@ -120,6 +121,14 @@ import KommunicateCore_iOS_SDK
120121
conversation.teamId = teamId
121122
return self
122123
}
124+
125+
/// To set pre fill message in Chat Bar while opening converwastion.
126+
/// - Parameter message: Pass the text that should be vissble on chat bar while opening the conversation. Only works with `launchConversation`
127+
@discardableResult
128+
@objc public func setPreFilledMessage(_ messsage: String) -> KMConversationBuilder {
129+
conversation.prefilledMessage = messsage
130+
return self
131+
}
123132

124133
/// Finally call the build method on the KMConversationBuilder to build the KMConversation
125134
@objc public func build() -> KMConversation {

0 commit comments

Comments
 (0)