Skip to content

Commit

Permalink
Version 3.41.2
Browse files Browse the repository at this point in the history
  • Loading branch information
webim committed Feb 2, 2024
1 parent d5c0623 commit ac1780a
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pod 'WebimMobileSDK'

Add following line to your **Cartfile**:
```
github "webim/webim-client-sdk-ios" ~> 3.41.1
github "webim/webim-client-sdk-ios" ~> 3.41.2
```

### Swift Package Manager
Expand All @@ -41,7 +41,7 @@ Previous _Objective-C_ version (version numbers 2.x.x) can be reached from **ver

## Release notes

* `send(message:compleionHandler)` fixed.
* New method `set(requestHeader: )` .

## Example

Expand Down
2 changes: 1 addition & 1 deletion WebimMobileSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'WebimMobileSDK'
s.version = '3.41.0'
s.version = '3.41.2'

s.author = { 'Webim.ru Ltd.' => '[email protected]' }
s.homepage = 'https://webim.ru/integration/mobile-sdk/ios-sdk-howto/'
Expand Down
11 changes: 9 additions & 2 deletions WebimMobileSDK/Backend/AbstractRequestLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ class AbstractRequestLoop {
private var currentDataTask: URLSessionDataTask?
let completionHandlerExecutor: ExecIfNotDestroyedHandlerExecutor?
let internalErrorListener: InternalErrorListener?
let requestHeader: [String: String]?

init(completionHandlerExecutor: ExecIfNotDestroyedHandlerExecutor?,
internalErrorListener: InternalErrorListener?) {
internalErrorListener: InternalErrorListener?,
requestHeader: [String: String]?) {
self.completionHandlerExecutor = completionHandlerExecutor
self.internalErrorListener = internalErrorListener
self.requestHeader = requestHeader
}

// MARK: - Methods
Expand Down Expand Up @@ -102,7 +105,11 @@ class AbstractRequestLoop {

func perform(request: URLRequest) throws -> Data {
var requestWithUserAgent = request
requestWithUserAgent.setValue("iOS: Webim-Client 3.41.1; (\(UIDevice.current.model); \(UIDevice.current.systemVersion)); Bundle ID and version: \(Bundle.main.bundleIdentifier ?? "none") \(Bundle.main.infoDictionary?["CFBundleVersion"] ?? "none")", forHTTPHeaderField: "User-Agent")
requestWithUserAgent.setValue("iOS: Webim-Client 3.41.2; (\(UIDevice.current.model); \(UIDevice.current.systemVersion)); Bundle ID and version: \(Bundle.main.bundleIdentifier ?? "none") \(Bundle.main.infoDictionary?["CFBundleVersion"] ?? "none")", forHTTPHeaderField: "User-Agent")

for (key, value) in requestHeader ?? [:] {
requestWithUserAgent.setValue(value, forHTTPHeaderField: key)
}

var errorCounter = 0
var connectionErrorCounter = 0
Expand Down
9 changes: 5 additions & 4 deletions WebimMobileSDK/Backend/ActionRequestLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ class ActionRequestLoop: AbstractRequestLoop {

// MARK: - Initialization
init(completionHandlerExecutor: ExecIfNotDestroyedHandlerExecutor,
internalErrorListener: InternalErrorListener, notFatalErrorHandler: NotFatalErrorHandler?) {
super.init(completionHandlerExecutor: completionHandlerExecutor, internalErrorListener: internalErrorListener)
internalErrorListener: InternalErrorListener, notFatalErrorHandler: NotFatalErrorHandler?, requestHeader: [String: String]?) {
super.init(completionHandlerExecutor: completionHandlerExecutor, internalErrorListener: internalErrorListener, requestHeader: requestHeader)
}

init(completionHandlerExecutor: ExecIfNotDestroyedHandlerExecutor,
internalErrorListener: InternalErrorListener) {
super.init(completionHandlerExecutor: completionHandlerExecutor, internalErrorListener: internalErrorListener)
internalErrorListener: InternalErrorListener,
requestHeader: [String: String]?) {
super.init(completionHandlerExecutor: completionHandlerExecutor, internalErrorListener: internalErrorListener, requestHeader: requestHeader)
}

// MARK: - Methods
Expand Down
7 changes: 4 additions & 3 deletions WebimMobileSDK/Backend/DeltaRequestLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class DeltaRequestLoop: AbstractRequestLoop {
visitorJSONString: String?,
sessionID: String?,
prechat:String?,
authorizationData: AuthorizationData?) {
authorizationData: AuthorizationData?,
requestHeader: [String: String]?) {
self.deltaCallback = deltaCallback
self.sessionParametersListener = sessionParametersListener
self.baseURL = baseURL
Expand All @@ -97,7 +98,7 @@ class DeltaRequestLoop: AbstractRequestLoop {
self.providedAuthenticationTokenStateListener = providedAuthenticationTokenStateListener
self.providedAuthenticationToken = providedAuthenticationToken
self.prechat = prechat
super.init(completionHandlerExecutor: completionHandlerExecutor, internalErrorListener: internalErrorListener)
super.init(completionHandlerExecutor: completionHandlerExecutor, internalErrorListener: internalErrorListener, requestHeader: requestHeader)
}

// MARK: - Methods
Expand Down Expand Up @@ -191,7 +192,7 @@ class DeltaRequestLoop: AbstractRequestLoop {
func requestInitialization() {
let url = URL(string: baseURL + ServerPathSuffix.initPath.rawValue + "?" + getInitializationParameterString())
var request = URLRequest(url: url!)
request.setValue("3.41.1", forHTTPHeaderField: Parameter.webimSDKVersion.rawValue)
request.setValue("3.41.2", forHTTPHeaderField: Parameter.webimSDKVersion.rawValue)
request.httpMethod = AbstractRequestLoop.HTTPMethods.get.rawValue

do {
Expand Down
2 changes: 1 addition & 1 deletion WebimMobileSDK/Backend/FAQRequestLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FAQRequestLoop: AbstractRequestLoop {
// MARK: - Initialization
init(completionHandlerExecutor: ExecIfNotDestroyedFAQHandlerExecutor) {
self.completionFAQHandlerExecutor = completionHandlerExecutor
super.init(completionHandlerExecutor: nil, internalErrorListener: nil)
super.init(completionHandlerExecutor: nil, internalErrorListener: nil, requestHeader: nil)
}

// MARK: - Methods
Expand Down
13 changes: 11 additions & 2 deletions WebimMobileSDK/Backend/WebimClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ final class WebimClientBuilder {
private var location: String?
private var providedAuthenticationToken: String?
private weak var providedAuthenticationTokenStateListener: ProvidedAuthorizationTokenStateListener?
private var requestHeader: [String: String]?
private var sessionID: String?
private var sessionParametersListener: SessionParametersListener?
private var title: String?
Expand Down Expand Up @@ -113,6 +114,12 @@ final class WebimClientBuilder {
return self
}

func set(requestHeader: [String: String]?) -> WebimClientBuilder {
self.requestHeader = requestHeader

return self
}

func set(sessionID: String?) -> WebimClientBuilder {
self.sessionID = sessionID

Expand Down Expand Up @@ -178,7 +185,8 @@ final class WebimClientBuilder {

let actionRequestLoop = ActionRequestLoop(completionHandlerExecutor: completionHandlerExecutor,
internalErrorListener: internalErrorListener,
notFatalErrorHandler: notFatalErrorHandler)
notFatalErrorHandler: notFatalErrorHandler,
requestHeader: requestHeader)

actionRequestLoop.set(authorizationData: authorizationData)

Expand Down Expand Up @@ -221,7 +229,8 @@ final class WebimClientBuilder {
visitorJSONString: visitorJSONString,
sessionID: sessionID,
prechat: prechat,
authorizationData: authorizationData
authorizationData: authorizationData,
requestHeader: requestHeader
)

return WebimClient(withActionRequestLoop: actionRequestLoop,
Expand Down
7 changes: 5 additions & 2 deletions WebimMobileSDK/Implementation/WebimSessionImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ final class WebimSessionImpl {
webimAlert: WebimAlert?,
prechat: String?,
multivisitorSection: String,
onlineStatusRequestFrequencyInMillis: Int64?) -> WebimSessionImpl {
onlineStatusRequestFrequencyInMillis: Int64?,
requestHeader: [String: String]?) -> WebimSessionImpl {

let visitorName = visitorFields?.getID() ?? "anonymous"
let mobileChatInstance = mobileChatInstance ?? "default"
Expand Down Expand Up @@ -149,7 +150,8 @@ final class WebimSessionImpl {
webimAlert: webimAlert,
prechat: prechat,
multivisitorSection: multivisitorSection,
onlineStatusRequestFrequencyInMillis: onlineStatusRequestFrequencyInMillis
onlineStatusRequestFrequencyInMillis: onlineStatusRequestFrequencyInMillis,
requestHeader: requestHeader
)
}
return session
Expand Down Expand Up @@ -229,6 +231,7 @@ final class WebimSessionImpl {
.set(visitorJSONString: visitorJSON)
.set(providedAuthenticationTokenStateListener: providedAuthorizationTokenStateListener,
providedAuthenticationToken: providedAuthorizationToken)
.set(requestHeader: requestHeader)
.set(sessionID: sessionID)
.set(authorizationData: authorizationData)
.set(completionHandlerExecutor: ExecIfNotDestroyedHandlerExecutor(sessionDestroyer: sessionDestroyer,
Expand Down
21 changes: 20 additions & 1 deletion WebimMobileSDK/Webim.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public final class SessionBuilder {
private weak var webimAlert: WebimAlert?
private var prechat: String?
private var onlineStatusRequestFrequencyInMillis: Int64?
private var requestHeader: [String: String]?

// MARK: - Methods

Expand Down Expand Up @@ -492,6 +493,23 @@ public final class SessionBuilder {

return self
}

/**
Adds header to network requests.
- parameter requestHeader:
Request header.
- returns:
`SessionBuilder` object with requestLocationFrequencyInMs parameter set.
- author:
Nikita Kaberov
- copyright:
2024 Webim
*/
public func set(requestHeader: [String: String]) -> SessionBuilder {
self.requestHeader = requestHeader

return self
}

/**
Method to pass WebimLogger object.
Expand Down Expand Up @@ -641,7 +659,8 @@ public final class SessionBuilder {
webimAlert: webimAlert,
prechat: prechat,
multivisitorSection: multivisitorSection,
onlineStatusRequestFrequencyInMillis: onlineStatusRequestFrequencyInMillis) as WebimSession
onlineStatusRequestFrequencyInMillis: onlineStatusRequestFrequencyInMillis,
requestHeader: requestHeader) as WebimSession
}

/**
Expand Down

0 comments on commit ac1780a

Please sign in to comment.