From 1badbcc3713d74df67d4a2690a52d171831aa374 Mon Sep 17 00:00:00 2001 From: SEAN Date: Wed, 26 Nov 2025 18:12:31 +0900 Subject: [PATCH] 1 --- Sources/tcmpush/tcmpush.swift | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Sources/tcmpush/tcmpush.swift diff --git a/Sources/tcmpush/tcmpush.swift b/Sources/tcmpush/tcmpush.swift new file mode 100644 index 0000000..c67d5bb --- /dev/null +++ b/Sources/tcmpush/tcmpush.swift @@ -0,0 +1,59 @@ +// +// tcmpush.swift +// tcmpush +// +// Created by TA9 on 11/26/25. +// + +import UIKit +import FirebaseCore +import FirebaseMessaging + +public class TCMPush: NSObject { + + public static let shared: TCMPush = { + let inistance = TCMPush() + return inistance + }() + + private override init() {} + + public var isDebugMode: Bool = false + + public func printLog(_ object: T,_ function: String = #function, _ line: Int = #line){ + if isDebugMode { + Swift.print(""" + _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ + | NAME = [\(function)] || LINE = [\(line)] + |>>> PRINT = \(object) + """) + } + } + public func configure() { + if FirebaseApp.app() == nil { + FirebaseApp.configure() + printLog("[TCMPush] FirebaseApp configured") + } + } + + public func setAPNSToken(_ deviceId: Data){ + Messaging.messaging().apnsToken = deviceId + printLog("[TCMPush] set APNS Token: \(deviceId)") + } + + public func getFCMToken(completion: @escaping (String?, Error?) -> Void) { + Messaging.messaging().token { [weak self] token, error in + guard let self = self else { return } + if let error = error { + self.printLog("[TCMPush] 토큰 가져오기 실패: \(error.localizedDescription)") + completion(nil, error) + } else if let token = token { + self.printLog("[TCMPush] 토큰 획득 성공: \(token)") + completion(token, nil) + } + } + } + + + +}