Skip to content

Commit

Permalink
Version 3.41.3
Browse files Browse the repository at this point in the history
  • Loading branch information
webim committed Feb 5, 2024
1 parent ac1780a commit 8c16113
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 6 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.2
github "webim/webim-client-sdk-ios" ~> 3.41.3
```

### 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

* New method `set(requestHeader: )` .
* New method `setRequestHeader(key:value: )`.

## 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.2'
s.version = '3.41.3'

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

init(completionHandlerExecutor: ExecIfNotDestroyedHandlerExecutor?,
internalErrorListener: InternalErrorListener?,
Expand Down Expand Up @@ -105,7 +105,7 @@ class AbstractRequestLoop {

func perform(request: URLRequest) throws -> Data {
var requestWithUserAgent = request
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")
requestWithUserAgent.setValue("iOS: Webim-Client 3.41.3; (\(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)
Expand Down Expand Up @@ -276,6 +276,14 @@ class AbstractRequestLoop {
return newData
}

func setRequestHeader(key: String, value: String) {
if requestHeader != nil {
requestHeader?[key] = value
} else {
requestHeader = [key: value]
}
}

// MARK: Private methods

private func blockUntilPaused() {
Expand Down
2 changes: 1 addition & 1 deletion WebimMobileSDK/Backend/DeltaRequestLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,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.2", forHTTPHeaderField: Parameter.webimSDKVersion.rawValue)
request.setValue("3.41.3", forHTTPHeaderField: Parameter.webimSDKVersion.rawValue)
request.httpMethod = AbstractRequestLoop.HTTPMethods.get.rawValue

do {
Expand Down
5 changes: 5 additions & 0 deletions WebimMobileSDK/Backend/WebimClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ final class WebimClient {
return webimActions
}

func setRequestHeader(key: String, value: String) {
deltaRequestLoop.setRequestHeader(key: key, value: value)
actionRequestLoop.setRequestHeader(key: key, value: value)
}

}

// MARK: -
Expand Down
6 changes: 6 additions & 0 deletions WebimMobileSDK/Implementation/WebimSessionImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,12 @@ extension WebimSessionImpl: WebimSession {
webimClient.set(deviceToken: deviceToken)
}

func setRequestHeader(key: String, value: String) throws {
try checkAccess()

webimClient.setRequestHeader(key: key, value: value)
}


// MARK: Private methods
private func checkAccess() throws {
Expand Down
16 changes: 16 additions & 0 deletions WebimMobileSDK/WebimSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ public protocol WebimSession: class {
*/
func set(deviceToken: String) throws

/**
This method allows to manually set request header after the session is created.
- parameter key:
Header key.
- parameter value:
Header value.
- throws:
`AccessError.invalidThread` if the method was called not from the thread the WebimSession was created in.
`AccessError.invalidSession` if WebimSession was destroyed.
- author:
Nikita Kaberov
- copyright:
2024 Webim
*/
func setRequestHeader(key: String, value: String) throws

}

// MARK: -
Expand Down

0 comments on commit 8c16113

Please sign in to comment.