Skip to content

Commit

Permalink
[Feature/#341] 통신 API 헤더에 부가 정보들 추가 #352
Browse files Browse the repository at this point in the history
  • Loading branch information
JongHoooon authored Nov 8, 2024
1 parent 559f6c8 commit c122bea
Showing 1 changed file with 26 additions and 0 deletions.
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

0 comments on commit c122bea

Please sign in to comment.