Skip to content

Commit

Permalink
Merge pull request #1302 from wakmusic/1299-empty-token
Browse files Browse the repository at this point in the history
🔀 :: (#1299) 빈토큰 미전송
  • Loading branch information
baekteun authored Sep 22, 2024
2 parents 7a5c53e + 26aa571 commit d1ec057
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Projects/Domains/BaseDomain/Sources/BasePlugin/BasePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public struct BasePlugin: PluginType {
}

for type in baseInfoTypes {
newJson[type.apiKey] = typeToValue(with: type)
guard let value = typeToValue(with: type) else { continue }
newJson[type.apiKey] = value
}

guard let newBodyData = try? JSONSerialization.data(withJSONObject: newJson, options: []) else {
Expand All @@ -60,7 +61,7 @@ public struct BasePlugin: PluginType {
}

private extension BasePlugin {
func typeToValue(with type: BaseInfoType) -> String {
func typeToValue(with type: BaseInfoType) -> String? {
switch type {
case .os:
return "ios"
Expand All @@ -75,18 +76,17 @@ private extension BasePlugin {

func fetchDeviceID() -> String {
let deviceIDFromKeychain: String = keychain.load(type: .deviceID)
let uuidString: String = UIDevice.current.identifierForVendor?.uuidString ?? ""
let uuidString: String? = UIDevice.current.identifierForVendor?.uuidString

if deviceIDFromKeychain.isEmpty {
if deviceIDFromKeychain.isEmpty, let uuidString {
keychain.save(type: .deviceID, value: uuidString)
return uuidString

} else {
return deviceIDFromKeychain
}
}

func fetchPushToken() -> String {
return Messaging.messaging().fcmToken ?? ""
func fetchPushToken() -> String? {
return Messaging.messaging().fcmToken
}
}

0 comments on commit d1ec057

Please sign in to comment.