Skip to content

Commit 1b7664b

Browse files
Merge pull request #492 from Kommunicate-io/remove-applozic-references
[CM-2362] [CM-2363] [CM-2359] Applozic to Kommunicate: iOS SDK Transformation
2 parents 97c2b0b + 7c39b8f commit 1b7664b

15 files changed

+148
-85
lines changed

.github/workflows/ios-automation-test.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ jobs:
1717
# Only run this job when the base branch is master
1818
if: github.event.pull_request.base.ref == 'master'
1919
runs-on: macos-latest
20-
timeout-minutes: 10
20+
timeout-minutes: 15
2121

2222
steps:
2323
- name: Checkout Repository
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525

2626
- name: Set up Xcode
2727
uses: maxim-lobanov/setup-xcode@v1
2828
with:
29-
xcode-version: '16.1.0'
29+
xcode-version: '16.2'
3030

3131
- name: Run Linter Check
3232
run: |
@@ -37,7 +37,7 @@ jobs:
3737

3838
- name: Post Lint Test Results to PR
3939
if: github.event_name == 'pull_request' && success()
40-
uses: actions/github-script@v6
40+
uses: actions/github-script@v7
4141
with:
4242
script: |
4343
const comment = `✅ **iOS Lint Test Result**\nCongratulations! Linter Check Passed Successfully 🎉`;
@@ -65,17 +65,17 @@ jobs:
6565
build-and-test:
6666
name: Build and Test
6767
runs-on: macos-latest
68-
timeout-minutes: 45
68+
timeout-minutes: 90
6969

7070
steps:
7171
# Step 1: Checkout the code
7272
- name: Checkout Repository
73-
uses: actions/checkout@v3
73+
uses: actions/checkout@v4
7474

7575
# Step 2: Fetch PR Branch Information
7676
- name: Fetch PR Comments
7777
id: fetch-branches
78-
uses: actions/github-script@v6
78+
uses: actions/github-script@v7
7979
with:
8080
script: |
8181
const prBody = context.payload.pull_request?.body;
@@ -101,7 +101,7 @@ jobs:
101101
- name: Set up Xcode
102102
uses: maxim-lobanov/setup-xcode@v1
103103
with:
104-
xcode-version: '16.1.0'
104+
xcode-version: '16.2'
105105

106106
# Step 4: Set Environment Variables
107107
- name: Set Environment Variables
@@ -209,7 +209,7 @@ jobs:
209209
# Step 9: Post Test Results as a PR Comment
210210
- name: Post Test Results to PR
211211
if: github.event_name == 'pull_request'
212-
uses: actions/github-script@v6
212+
uses: actions/github-script@v7
213213
with:
214214
script: |
215215
const fs = require('fs');

Example/Kommunicate/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
let kmApplocalNotificationHandler = KMAppLocalNotification.appLocalNotificationHandler()
4141
kmApplocalNotificationHandler?.dataConnectionNotificationHandler()
4242

43-
if KMUserDefaultHandler.isLoggedIn() {
43+
if Kommunicate.isLoggedIn {
4444
// Get login screen from storyboard and present it
4545
if let viewController = UIStoryboard(name: "Main", bundle: nil)
4646
.instantiateViewController(withIdentifier: "NavViewController") as? UINavigationController

Example/Kommunicate_ExampleUITests/KommunicateResolveAndAssignmentUITests.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ class KommunicateResolveAndAssignmentUITests: XCTestCase {
4141
func testRestartConversation () {
4242
let app = beforeTest_Launch_NewConversation()
4343
waitFor(object: app) { $0.exists }
44+
let inputView = app.otherElements[AppScreen.chatBar].children(matching: .textView).matching(identifier: AppTextFeild.chatTextView).firstMatch
45+
waitFor(object: inputView) { $0.exists }
46+
inputView.tap()
47+
inputView.tap()
48+
inputView.tap()
4449
app.typeText(GroupData.typeText) // typing message
4550
app.buttons[InAppButton.ConversationScreen.send].tap() // sending message in group
4651
sleep(3) /// To wait for response
@@ -75,8 +80,7 @@ class KommunicateResolveAndAssignmentUITests: XCTestCase {
7580
sleep(2)
7681

7782
app.buttons[InAppButton.ConversationScreen.restartConversation].tap()
78-
79-
let inputView = app.otherElements[AppScreen.chatBar].children(matching: .textView).matching(identifier: AppTextFeild.chatTextView).firstMatch
83+
8084
waitFor(object: inputView) { $0.exists }
8185
inputView.tap()
8286
inputView.tap()

Example/Tests/KommunicateTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ class KommunicateTests: XCTestCase {
3333
}
3434
}
3535

36-
class ApplozicClientMock: ApplozicClient {
36+
class KommunicateClientMock: KommunicateClient {
3737
static var messageCount = 1
3838

3939
override func getLatestMessages(_: Bool, withCompletionHandler completion: ((NSMutableArray?, Error?) -> Void)!) {
4040
let messageList: NSMutableArray = []
41-
for _ in 0 ..< ApplozicClientMock.messageCount {
41+
for _ in 0 ..< KommunicateClientMock.messageCount {
4242
let message = ALMessage()
4343
messageList.add(message)
4444
}
@@ -89,7 +89,7 @@ class KommunicateTests: XCTestCase {
8989

9090
// Test when multiple threads are present, method to show conversation list
9191
// gets called.
92-
ApplozicClientMock.messageCount = 2
92+
KommunicateClientMock.messageCount = 2
9393
KommunicateMock.createAndShowConversation(from: dummyViewController, completion: {
9494
_ in
9595
XCTAssertTrue(KommunicateMock.showConversationsCalled)
@@ -107,7 +107,7 @@ class KommunicateTests: XCTestCase {
107107
}
108108

109109
func testCreateConversationWithCustomData() {
110-
KommunicateMock.applozicClientType = ApplozicClientMock.self
110+
KommunicateMock.applozicClientType = KommunicateClientMock.self
111111
let expectation = self.expectation(description: "Completion handler called")
112112

113113
for bundle in Bundle.allBundles {
@@ -155,7 +155,7 @@ class KommunicateTests: XCTestCase {
155155
}
156156

157157
func testCreateAndLaunchConversationWithCustomData() {
158-
KommunicateMock.applozicClientType = ApplozicClientMock.self
158+
KommunicateMock.applozicClientType = KommunicateClientMock.self
159159
let expectation = self.expectation(description: "Completion handler called")
160160

161161
for bundle in Bundle.allBundles {
@@ -211,7 +211,7 @@ class KommunicateTests: XCTestCase {
211211
}
212212

213213
func testUpdateConversationAssignee() {
214-
KommunicateMock.applozicClientType = ApplozicClientMock.self
214+
KommunicateMock.applozicClientType = KommunicateClientMock.self
215215
let expectation = self.expectation(description: "Completion handler called")
216216
let assigneeId = "alex-nwqih"
217217

@@ -261,7 +261,7 @@ class KommunicateTests: XCTestCase {
261261
}
262262

263263
func testUpdateTeamID() {
264-
KommunicateMock.applozicClientType = ApplozicClientMock.self
264+
KommunicateMock.applozicClientType = KommunicateClientMock.self
265265
let expectation = self.expectation(description: "Completion handler called")
266266
let teamID = "107732724"
267267

@@ -311,7 +311,7 @@ class KommunicateTests: XCTestCase {
311311
}
312312

313313
func testUpdateConversationMetadata() {
314-
KommunicateMock.applozicClientType = ApplozicClientMock.self
314+
KommunicateMock.applozicClientType = KommunicateClientMock.self
315315
let expectation = self.expectation(description: "Completion handler called")
316316
let metaData = ["name": "Alice", "city": "London", "hobby": "Painting"]
317317

@@ -361,7 +361,7 @@ class KommunicateTests: XCTestCase {
361361
}
362362

363363
func testSendMessageFunction() {
364-
KommunicateMock.applozicClientType = ApplozicClientMock.self
364+
KommunicateMock.applozicClientType = KommunicateClientMock.self
365365
let expectation = self.expectation(description: "Completion handler called")
366366

367367
let kmConversation = KMConversationBuilder()
@@ -417,7 +417,7 @@ class KommunicateTests: XCTestCase {
417417
}
418418

419419
func testOpenPerticularConversation() {
420-
KommunicateMock.applozicClientType = ApplozicClientMock.self
420+
KommunicateMock.applozicClientType = KommunicateClientMock.self
421421
let expectation = self.expectation(description: "Completion handler called")
422422

423423
// Dummy View Controller For Testing
@@ -456,7 +456,7 @@ class KommunicateTests: XCTestCase {
456456
}
457457

458458
func testUpdateConversationFunction() {
459-
KommunicateMock.applozicClientType = ApplozicClientMock.self
459+
KommunicateMock.applozicClientType = KommunicateClientMock.self
460460
let expectation = self.expectation(description: "Completion handler called")
461461

462462
let kmConversation = KMConversationBuilder()
@@ -531,7 +531,7 @@ class KommunicateTests: XCTestCase {
531531
}
532532

533533
func testIsSingleThreaded() {
534-
KommunicateMock.applozicClientType = ApplozicClientMock.self
534+
KommunicateMock.applozicClientType = KommunicateClientMock.self
535535
let expectation = self.expectation(description: "Completion handler called")
536536
let kmConversation = KMConversationBuilder()
537537
.useLastConversation(true)

Example/Tests/PaymentTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class PaymentTests: XCTestCase {
6363
}
6464
}
6565

66-
class UserDefaultsHandlerMock: ALUserDefaultsHandler {
66+
class UserDefaultsHandlerMock: KMCoreUserDefaultsHandler {
6767
static var pricingPackage: Int16 = 101
6868
static var userRole = Int16(AL_APPLICATION_WEB_ADMIN.rawValue)
6969

Sources/Kommunicate/Classes/ConversationDetail.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ConversationDetail {
5656
completion(contact, alChannel)
5757
return
5858
}
59-
for case let userDetail as ALUserDetail in userDetails {
59+
for case let userDetail as KMCoreUserDetail in userDetails {
6060
strongSelf.contactDbService.update(userDetail)
6161
}
6262
(assignee, alChannel) = strongSelf.conversationAssignee(groupId: groupId, userId: userId)

Sources/Kommunicate/Classes/Extensions/UIButton+Extension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// UIButton+Extension.swift
3-
// Applozic
3+
// Kommunicate
44
//
55
// Created by Mukesh on 03/12/19.
66
//

Sources/Kommunicate/Classes/KMConversationListViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class KMConversationListViewController: ALKBaseViewController, Localizabl
3636
public var dbService = ALMessageDBService()
3737
public var viewModel = ALKConversationListViewModel()
3838

39-
var isSingleThreadedEnabled = ALApplozicSettings.getIsSingleThreadedEnabled()
39+
var isSingleThreadedEnabled = KMCoreSettings.getIsSingleThreadedEnabled()
4040

4141
enum Padding {
4242
enum NoConversationLabel {
@@ -192,7 +192,7 @@ public class KMConversationListViewController: ALKBaseViewController, Localizabl
192192
super.viewDidLoad()
193193
setupMqtt()
194194
subscribeToConversation()
195-
isSingleThreadedEnabled = ALApplozicSettings.getIsSingleThreadedEnabled()
195+
isSingleThreadedEnabled = KMCoreSettings.getIsSingleThreadedEnabled()
196196
dbService.delegate = self
197197
viewModel.delegate = self
198198
setupSearchController()
@@ -781,7 +781,7 @@ extension KMConversationListViewController: ALMQTTConversationDelegate {
781781

782782
open func reloadData(forUserBlockNotification userId: String!, andBlockFlag _: Bool) {
783783
print("reload data")
784-
let userDetail = ALUserDetail()
784+
let userDetail = KMCoreUserDetail()
785785
userDetail.userId = userId
786786
viewModel.updateStatusFor(userDetail: userDetail)
787787
guard let viewController = navigationController?.visibleViewController as? KMConversationViewController else {
@@ -790,7 +790,7 @@ extension KMConversationListViewController: ALMQTTConversationDelegate {
790790
viewController.checkUserBlock()
791791
}
792792

793-
open func updateLastSeen(atStatus alUserDetail: ALUserDetail!) {
793+
open func updateLastSeen(atStatus alUserDetail: KMCoreUserDetail!) {
794794
print("Last seen updated")
795795
viewModel.updateStatusFor(userDetail: alUserDetail)
796796
guard let viewController = navigationController?.visibleViewController as? KMConversationViewController else {

Sources/Kommunicate/Classes/KMConversationService.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ public class KMConversationService: KMConservationServiceable, Localizable {
464464
}
465465

466466
let languageCode = NSLocale.preferredLanguages.first?.prefix(2)
467-
if languageCode?.description != ALUserDefaultsHandler.getDeviceDefaultLanguage() {
468-
ALUserDefaultsHandler.setDeviceDefaultLanguage(languageCode?.description)
467+
if languageCode?.description != KMCoreUserDefaultsHandler.getDeviceDefaultLanguage() {
468+
KMCoreUserDefaultsHandler.setDeviceDefaultLanguage(languageCode?.description)
469469
}
470470
updateMetadataChatContext(info: [ChannelMetadataKeys.kmUserLocale: languageCode as Any], metadata: metadata)
471471

@@ -604,7 +604,7 @@ public class KMConversationService: KMConservationServiceable, Localizable {
604604
return
605605
}
606606

607-
guard let zendeskAccountKey = ALApplozicSettings.getZendeskSdkAccountKey(),
607+
guard let zendeskAccountKey = KMCoreSettings.getZendeskSdkAccountKey(),
608608
!zendeskAccountKey.isEmpty,
609609
let clientChannelKey = channel.clientChannelKey,
610610
let metadata = channel.metadata,

Sources/Kommunicate/Classes/KMConversationViewController.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
233233

234234
func isBusinessHoursUIScreenVisible() {
235235
guard PricingPlan.shared.isBusinessPlanOrTrialPlan(),
236-
let applicationKey = ALUserDefaultsHandler.getApplicationKey(),
236+
let applicationKey = KMCoreUserDefaultsHandler.getApplicationKey(),
237237
let teamID = viewModel.assignedTeamId,
238238
let teamId = Int(teamID) else { return }
239239

@@ -290,8 +290,10 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
290290
teamID: Int
291291
) {
292292
if currentTime >= 2300 {
293-
let remainingTime = minutesBetween(start: currentTime, end: 2359) + 1
294-
DispatchQueue.main.asyncAfter(deadline: .now() + (TimeInterval(remainingTime) * 60) + 1) { [weak self] in
293+
let remainingTime = minutesBetween(start: currentTime, end: 0) // Time until next day 00:00
294+
let delay = TimeInterval(remainingTime * 60) // Convert to seconds
295+
296+
DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] in
295297
guard let kmBusinessHoursDataArray = self?.kmBusinessHoursDataArray else { return }
296298
self?.processBusinessHours(kmBusinessHoursDataArray, for: teamID)
297299
}
@@ -372,7 +374,8 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
372374

373375
private func recallBusinessHoursMessage(startTime: Int, endTime: Int, teamID: Int) {
374376
let remainingTime = minutesBetween(start: startTime, end: endTime)
375-
DispatchQueue.main.asyncAfter(deadline: .now() + (TimeInterval(remainingTime) * 60) + 1) { [weak self] in
377+
let delay = max(TimeInterval(remainingTime + 1) * 60, 1) // Ensures at least a 1s delay
378+
DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] in
376379
guard let kmBusinessHoursDataArray = self?.kmBusinessHoursDataArray else { return }
377380
self?.processBusinessHours(kmBusinessHoursDataArray, for: teamID)
378381
}
@@ -508,7 +511,7 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
508511
}
509512
})
510513
} else {
511-
guard let channelKey = viewModel.channelKey, let applicationKey = ALUserDefaultsHandler.getApplicationKey() else { return }
514+
guard let channelKey = viewModel.channelKey, let applicationKey = KMCoreUserDefaultsHandler.getApplicationKey() else { return }
512515
conversationService.awayMessageFor(applicationKey: applicationKey, groupId: channelKey, completion: {
513516
result in
514517
DispatchQueue.main.async {
@@ -764,7 +767,7 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
764767
if let channelId = weakSelf.viewModel.channelKey {
765768
KMCustomEventHandler.shared.publish(triggeredEvent: KMCustomEvent.restartConversationClick, data: ["conversationId": channelId])
766769
}
767-
guard let zendeskAccountKey = ALApplozicSettings.getZendeskSdkAccountKey(),
770+
guard let zendeskAccountKey = KMCoreSettings.getZendeskSdkAccountKey(),
768771
!zendeskAccountKey.isEmpty else { return }
769772
#if canImport(ChatProvidersSDK)
770773
// if zendesk is integrated, create a new conversation instead of restarting the conversation
@@ -781,7 +784,7 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
781784
switch result {
782785
case .success(let conversationId):
783786
#if canImport(ChatProvidersSDK)
784-
ALApplozicSettings.setLastZendeskConversationId(NSNumber(value: Int(conversationId) ?? 0))
787+
KMCoreSettings.setLastZendeskConversationId(NSNumber(value: Int(conversationId) ?? 0))
785788
#endif
786789
let convViewModel = ALKConversationViewModel(contactId: nil, channelKey: NSNumber(value: Int(conversationId) ?? 0), localizedStringFileName: Kommunicate.defaultConfiguration.localizedStringFileName, prefilledMessage: nil)
787790
// Update the View Model & refresh the View Controller

0 commit comments

Comments
 (0)