Skip to content

Commit

Permalink
ADD: SPM Setting - FCM
Browse files Browse the repository at this point in the history
  • Loading branch information
psychehose committed Aug 31, 2022
1 parent 7b10048 commit 6dd84c5
Show file tree
Hide file tree
Showing 192 changed files with 3,243 additions and 9,549 deletions.
14 changes: 7 additions & 7 deletions Hous-iOS-release.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
7702A0F128BD0C4900DA7712 /* Analytics in Frameworks */ = {isa = PBXBuildFile; productRef = 7702A0F028BD0C4900DA7712 /* Analytics */; };
7717A84D28BBB89700C449CC /* ThirdPartyLibraryManager in Frameworks */ = {isa = PBXBuildFile; productRef = 7717A84C28BBB89700C449CC /* ThirdPartyLibraryManager */; };
77393DE128BFBD2D00D78C94 /* FirebaseWrapper in Frameworks */ = {isa = PBXBuildFile; productRef = 77393DE028BFBD2D00D78C94 /* FirebaseWrapper */; };
777C666128A74A62000BECEA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 777C666028A74A62000BECEA /* AppDelegate.swift */; };
777C666328A74A62000BECEA /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 777C666228A74A62000BECEA /* SceneDelegate.swift */; };
777C666A28A74A63000BECEA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 777C666928A74A63000BECEA /* Assets.xcassets */; };
Expand Down Expand Up @@ -39,7 +39,7 @@
buildActionMask = 2147483647;
files = (
7717A84D28BBB89700C449CC /* ThirdPartyLibraryManager in Frameworks */,
7702A0F128BD0C4900DA7712 /* Analytics in Frameworks */,
77393DE128BFBD2D00D78C94 /* FirebaseWrapper in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -165,7 +165,7 @@
name = "Hous-iOS-release";
packageProductDependencies = (
7717A84C28BBB89700C449CC /* ThirdPartyLibraryManager */,
7702A0F028BD0C4900DA7712 /* Analytics */,
77393DE028BFBD2D00D78C94 /* FirebaseWrapper */,
);
productName = "Hous-iOS-release";
productReference = 777C665D28A74A62000BECEA /* Hous-iOS-release.app */;
Expand Down Expand Up @@ -814,14 +814,14 @@
/* End XCConfigurationList section */

/* Begin XCSwiftPackageProductDependency section */
7702A0F028BD0C4900DA7712 /* Analytics */ = {
isa = XCSwiftPackageProductDependency;
productName = Analytics;
};
7717A84C28BBB89700C449CC /* ThirdPartyLibraryManager */ = {
isa = XCSwiftPackageProductDependency;
productName = ThirdPartyLibraryManager;
};
77393DE028BFBD2D00D78C94 /* FirebaseWrapper */ = {
isa = XCSwiftPackageProductDependency;
productName = FirebaseWrapper;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 777C665528A74A62000BECEA /* Project object */;
Expand Down
7 changes: 5 additions & 2 deletions Hous-iOS-release/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
//

import UIKit
import Analytics
import FirebaseWrapper

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

AppLogService.Firebase.configure()

FirebaseConfigureService.Firebase.configure()
MessagingService.Firebase.configure()

AppLogService.Firebase.logEvent(
event: .appStart,
parameter: [:]
Expand Down
13 changes: 9 additions & 4 deletions ThirdPartyLibraryManager/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ let package = Package(
.library(
name: "ThirdPartyLibraryManager",
targets: ["ThirdPartyLibraryManager"]),
.library(name: "Analytics", targets: ["Analytics"]),
.library(
name: "FirebaseWrapper",
targets: ["FirebaseWrapper"]
),
],
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire.git", exact: "5.6.1"),
Expand All @@ -41,9 +44,10 @@ let package = Package(
.binaryTarget(name: "GoogleDataTransport", path: "./Vender/FirebaseAnalytics/GoogleDataTransport.xcframework"),
.binaryTarget(name: "GoogleUtilities", path: "./Vender/FirebaseAnalytics/GoogleUtilities.xcframework"),
.binaryTarget(name: "nanopb", path: "./Vender/FirebaseAnalytics/nanopb.xcframework"),
.binaryTarget(name: "FirebaseMessaging", path: "./Vender/FirebaseMessaging/FirebaseMessaging.xcframework"),

.target(
name: "Analytics",
name: "FirebaseWrapper",
dependencies: [
.target(name: "FBLPromises"),
.target(name: "FirebaseAnalytics"),
Expand All @@ -56,11 +60,12 @@ let package = Package(
.target(name: "GoogleAppMeasurementIdentitySupport"),
.target(name: "GoogleDataTransport"),
.target(name: "GoogleUtilities"),
.target(name: "nanopb")
.target(name: "nanopb"),
.target(name: "FirebaseMessaging"),
],
resources: [
.process("Resource")
]
)
),
]
)
11 changes: 0 additions & 11 deletions ThirdPartyLibraryManager/Sources/Analytics/AppLogService.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,20 @@
//
// Created by 김호세 on 2022/08/28.
//
import Foundation

import Foundation
import FirebaseAnalytics
import FirebaseCore

public class AppLogService { }

protocol FirebaseLogEventServicable {
func configure()
func logEvent(
event: AppLogEvent,
parameter: [String: Any]
)
}

final class FirebaseLogEventService: FirebaseLogEventServicable {
func configure() {
guard
let filePath = Bundle.module.path(forResource: "GoogleService-Info", ofType: "plist"),
let fileOption = FirebaseOptions(contentsOfFile: filePath)
else {
print("Error 발생 GoogleService-Info 파일을 읽을 수 없음.")
return
}

FirebaseApp.configure(options: fileOption)
}

func logEvent(
event: AppLogEvent,
parameter: [String: Any]
Expand All @@ -41,10 +29,6 @@ final class FirebaseLogEventService: FirebaseLogEventServicable {
public extension AppLogService {
class Firebase {
static var service: FirebaseLogEventServicable = FirebaseLogEventService()

public static func configure() {
service.configure()
}
public static func logEvent(
event: AppLogEvent,
parameter: [String: Any]
Expand All @@ -56,4 +40,3 @@ public extension AppLogService {
}
}
}

39 changes: 39 additions & 0 deletions ThirdPartyLibraryManager/Sources/FirebaseWrapper/Firebase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// File.swift
//
//
// Created by 김호세 on 2022/08/28.
//
import Foundation

import FirebaseAnalytics
import FirebaseCore


protocol FirebaseConfiguarable {
func configure()
}

final class FirebaseConfigure: FirebaseConfiguarable {
func configure() {
guard
let filePath = Bundle.module.path(forResource: "GoogleService-Info", ofType: "plist"),
let fileOption = FirebaseOptions(contentsOfFile: filePath)
else {
print("Error 발생 GoogleService-Info 파일을 읽을 수 없음.")
return
}

FirebaseApp.configure(options: fileOption)
}
}

public class FirebaseConfigureService {
public class Firebase {
static var service: FirebaseConfiguarable = FirebaseConfigure()
public static func configure() {
service.configure()
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// File.swift
//
//
// Created by 김호세 on 2022/09/01.
//

import Foundation
import FirebaseMessaging

protocol FirebaseMessagingServicable {
func configure()
func registerDeviceToken(deviceToken: Data)
func setAPNSToken(deviceToken: Data)
func deleteToken()
func printFCMToken()
}

public class MessagingService: NSObject { }

final class FirebaseMessagingService: NSObject { }

extension FirebaseMessagingService: FirebaseMessagingServicable {

func configure() {
Messaging.messaging().delegate = self
}

func registerDeviceToken(deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
}
func setAPNSToken(deviceToken: Data) {
Messaging.messaging().setAPNSToken(deviceToken, type: .unknown)
}
func deleteToken() {
Messaging.messaging().deleteToken { err in
print(err!)
}
}
func printFCMToken() {
Messaging.messaging().token { token, err in
print(token!)
}
}
}
public extension MessagingService {
class Firebase {
static var service: FirebaseMessagingServicable = FirebaseMessagingService()
public static func configure() {
service.configure()
}
public static func registerDeviceToken(deviceToken: Data) {
service.registerDeviceToken(deviceToken: deviceToken)
}
public static func setAPNSToken(deviceToken: Data) {
service.setAPNSToken(deviceToken: deviceToken)
}
public static func deleteToken() {
service.deleteToken()
}
public static func printFCMToken() {
service.printFCMToken()
}
}
}
extension FirebaseMessagingService: MessagingDelegate {
public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
guard let fcmToken = fcmToken else {
return
}
print("fcmToken in a module: ", fcmToken)
}
}
Binary file not shown.

This file was deleted.

Loading

0 comments on commit 6dd84c5

Please sign in to comment.