Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature/#341] 통신 API 헤더에 부가 정보들 추가 #352

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Projects/Core/Network/Sources/Interceptor/TokenInterceptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Foundation
import UIKit

import CoreKeyChainStore
import CoreLoggerInterface
Expand All @@ -30,7 +31,32 @@ public class TokenInterceptor: RequestInterceptor {
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
}

var deviceName: String {
if let simulatorModelIdentifier = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] {
return simulatorModelIdentifier
} else {
var systemInfo = utsname()
uname(&systemInfo)
let modelIdentifier = withUnsafePointer(to: &systemInfo.machine) {
$0.withMemoryRebound(to: CChar.self, capacity: 1) { ptr in
String(validatingUTF8: ptr)
}
}
return modelIdentifier ?? ""
}
}
let appVersion = (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String) ?? ""
let deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
var osVersion = UIDevice.current.systemVersion

urlRequest.setValue(appVersion, forHTTPHeaderField: "X-App-Version")
urlRequest.setValue(deviceName, forHTTPHeaderField: "X-Device-Model")
urlRequest.setValue(osVersion, forHTTPHeaderField: "X-OS-Version")
urlRequest.setValue(deviceID, forHTTPHeaderField: "X-Device-ID")
urlRequest.setValue("iOS", forHTTPHeaderField: "X-App-Platform")

print(urlRequest.headers)

completion(.success(urlRequest))
}

Expand Down