Skip to content

Commit

Permalink
Updated the podspec file for ChatUI with or without Zendesk SDK and m…
Browse files Browse the repository at this point in the history
…ade the code of Zendesk SDK Optional
  • Loading branch information
AbhijeetRanjan308 committed Oct 29, 2024
1 parent f02dda9 commit c20bf66
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
17 changes: 14 additions & 3 deletions Kommunicate.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/Kommunicate-io/Kommunicate-iOS-SDK.git', :tag => s.version }
s.ios.deployment_target = '13.0'
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.6'

s.default_subspec = 'Complete'

s.subspec 'Zendesk' do |with_zendesk|
with_zendesk.source_files = 'Sources/Kommunicate/Classes/**/*.{swift}'
with_zendesk.resources = 'Sources/Resources/**/*{lproj,storyboard,xib,xcassets,json,strings}'
with_zendesk.dependency 'KommunicateChatUI-iOS-SDK/Zendesk', '1.3.6'
end

s.subspec 'Complete' do |complete|
complete.source_files = 'Sources/Kommunicate/Classes/**/*.{swift}'
complete.resources = 'Sources/Resources/**/*{lproj,storyboard,xib,xcassets,json,strings}'
complete.dependency 'KommunicateChatUI-iOS-SDK', '1.3.6'
end
end
18 changes: 10 additions & 8 deletions Sources/Kommunicate/Classes/KMConversationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,14 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
if let channelId = weakSelf.viewModel.channelKey {
KMCustomEventHandler.shared.publish(triggeredEvent: KMCustomEvent.restartConversationClick, data: ["conversationId":channelId])
}

guard let zendeskAcckountKey = ALApplozicSettings.getZendeskSdkAccountKey(),
!zendeskAcckountKey.isEmpty else { return }
// if zendesk is integrated, create a new conversation instead of restarting the conversation
let zendeskHandler = KMZendeskChatHandler.shared
zendeskHandler.resetConfiguration()
zendeskHandler.initiateZendesk(key: zendeskAcckountKey)
#if canImport(ChatProvidersSDK)
guard let zendeskAcckountKey = ALApplozicSettings.getZendeskSdkAccountKey(),
!zendeskAcckountKey.isEmpty else { return }
// if zendesk is integrated, create a new conversation instead of restarting the conversation
let zendeskHandler = KMZendeskChatHandler.shared
zendeskHandler.resetConfiguration()
zendeskHandler.initiateZendesk(key: zendeskAcckountKey)
#endif
weakSelf.loadingStarted()
// Create a new conversation
let kmConversation = KMConversationBuilder()
Expand All @@ -531,8 +532,9 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
Kommunicate.createConversation(conversation: kmConversation) { result in
switch result {
case .success(let conversationId):
#if canImport(ChatProvidersSDK)
ALApplozicSettings.setLastZendeskConversationId(NSNumber(value: Int(conversationId) ?? 0))
#endif
let convViewModel = ALKConversationViewModel(contactId: nil, channelKey: NSNumber(value: Int(conversationId) ?? 0), localizedStringFileName: Kommunicate.defaultConfiguration.localizedStringFileName, prefilledMessage: nil)
// Update the View Model & refresh the View Controller
weakSelf.updateViewModelAndRefreshViewController(convViewModel, conversationId: NSNumber(value: Int(conversationId) ?? 0))
Expand Down
4 changes: 4 additions & 0 deletions Sources/Kommunicate/Classes/Kommunicate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,9 @@ open class Kommunicate: NSObject, Localizable {
let applozicClient = applozicClientType.init(applicationKey: KMUserDefaultHandler.getApplicationKey())
applozicClient?.logoutUser(completion: { error, _ in
Kommunicate.shared.clearUserDefaults()
#if canImport(ChatProvidersSDK)
KMZendeskChatHandler.shared.endChat()
#endif
guard error == nil else {
completion(.failure(KMError.api(error)))
return
Expand Down Expand Up @@ -676,6 +678,7 @@ open class Kommunicate: NSObject, Localizable {
- viewController: ViewController from which the group chat will be launched.
*/
open class func openZendeskChat(from: UIViewController,completion: @escaping (_ error: KommunicateError?) -> Void) {
#if canImport(ChatProvidersSDK)
let zendeskHandler = KMZendeskChatHandler.shared
guard let accountKey = ALApplozicSettings.getZendeskSdkAccountKey(), !accountKey.isEmpty else {
completion(.zendeskKeyNotPresent)
Expand Down Expand Up @@ -735,6 +738,7 @@ open class Kommunicate: NSObject, Localizable {
bool == true ? completion(nil) : completion(.conversationOpenFailed)
print("Opening Existing conversation which is assigned to BOT")
})
#endif
}

/**
Expand Down

0 comments on commit c20bf66

Please sign in to comment.