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

[#63] Firebase RemoteConfig 연동 #91

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
25 changes: 25 additions & 0 deletions Soomsil-USaint.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
02C46D912D0F45B200A3E717 /* RxRelay in Frameworks */ = {isa = PBXBuildFile; productRef = 02C46D902D0F45B200A3E717 /* RxRelay */; };
7B75DB312D3A374B00FF2FBE /* ComposableArchitecture in Frameworks */ = {isa = PBXBuildFile; productRef = 7B75DB302D3A374B00FF2FBE /* ComposableArchitecture */; };
7BA4D7D32D17FAE700CF6689 /* Rusaint in Frameworks */ = {isa = PBXBuildFile; productRef = 7BA4D7D22D17FAE700CF6689 /* Rusaint */; };
B96F06662D63882B0047D33D /* FirebaseCore in Frameworks */ = {isa = PBXBuildFile; productRef = B96F06652D63882B0047D33D /* FirebaseCore */; };
B96F06682D63882B0047D33D /* FirebaseRemoteConfig in Frameworks */ = {isa = PBXBuildFile; productRef = B96F06672D63882B0047D33D /* FirebaseRemoteConfig */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -54,7 +56,9 @@
02C46CF52D0F2E9300A3E717 /* YDS-SwiftUI in Frameworks */,
02C46D8F2D0F45B200A3E717 /* RxCocoa in Frameworks */,
7B75DB312D3A374B00FF2FBE /* ComposableArchitecture in Frameworks */,
B96F06662D63882B0047D33D /* FirebaseCore in Frameworks */,
02C46D8D2D0F45B200A3E717 /* RxBlocking in Frameworks */,
B96F06682D63882B0047D33D /* FirebaseRemoteConfig in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -105,6 +109,8 @@
02C46D902D0F45B200A3E717 /* RxRelay */,
7BA4D7D22D17FAE700CF6689 /* Rusaint */,
7B75DB302D3A374B00FF2FBE /* ComposableArchitecture */,
B96F06652D63882B0047D33D /* FirebaseCore */,
B96F06672D63882B0047D33D /* FirebaseRemoteConfig */,
);
productName = "Rusaint-iOS";
productReference = 02C46CBE2D0F138700A3E717 /* Soomsil-USaint.app */;
Expand Down Expand Up @@ -140,6 +146,7 @@
02C46D8B2D0F45B200A3E717 /* XCRemoteSwiftPackageReference "RxSwift" */,
7BA4D7D12D17FAE700CF6689 /* XCRemoteSwiftPackageReference "rusaint-ios" */,
7B75DB2F2D3A374B00FF2FBE /* XCRemoteSwiftPackageReference "swift-composable-architecture" */,
B96F06642D63882B0047D33D /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = 02C46CBF2D0F138700A3E717 /* Products */;
Expand Down Expand Up @@ -435,6 +442,14 @@
minimumVersion = 0.8.2;
};
};
B96F06642D63882B0047D33D /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/firebase/firebase-ios-sdk";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 11.8.1;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand Down Expand Up @@ -478,6 +493,16 @@
package = 7BA4D7D12D17FAE700CF6689 /* XCRemoteSwiftPackageReference "rusaint-ios" */;
productName = Rusaint;
};
B96F06652D63882B0047D33D /* FirebaseCore */ = {
isa = XCSwiftPackageProductDependency;
package = B96F06642D63882B0047D33D /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseCore;
};
B96F06672D63882B0047D33D /* FirebaseRemoteConfig */ = {
isa = XCSwiftPackageProductDependency;
package = B96F06642D63882B0047D33D /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseRemoteConfig;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 02C46CB62D0F138700A3E717 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
{
"originHash" : "3fad13c882a08211597ca586b50a9eb013bc8775f1ce7024a83dc890cfa545e1",
"originHash" : "2cd7be355296c8d8b7324fc9365a54f1715e432052a886a0c719e2356aa2c54f",
"pins" : [
{
"identity" : "abseil-cpp-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/abseil-cpp-binary.git",
"state" : {
"revision" : "194a6706acbd25e4ef639bcaddea16e8758a3e27",
"version" : "1.2024011602.0"
}
},
{
"identity" : "app-check",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/app-check.git",
"state" : {
"revision" : "61b85103a1aeed8218f17c794687781505fbbef5",
"version" : "11.2.0"
}
},
{
"identity" : "combine-schedulers",
"kind" : "remoteSourceControl",
Expand All @@ -10,6 +28,69 @@
"version" : "1.0.3"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk",
"state" : {
"revision" : "6318278e8e64d21f0fdcc69004395e4d34048aaf",
"version" : "11.8.1"
}
},
{
"identity" : "googleappmeasurement",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleAppMeasurement.git",
"state" : {
"revision" : "be0881ff728eca210ccb628092af400c086abda3",
"version" : "11.7.0"
}
},
{
"identity" : "googledatatransport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleDataTransport.git",
"state" : {
"revision" : "617af071af9aa1d6a091d59a202910ac482128f9",
"version" : "10.1.0"
}
},
{
"identity" : "googleutilities",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleUtilities.git",
"state" : {
"revision" : "53156c7ec267db846e6b64c9f4c4e31ba4cf75eb",
"version" : "8.0.2"
}
},
{
"identity" : "grpc-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/grpc-binary.git",
"state" : {
"revision" : "f56d8fc3162de9a498377c7b6cea43431f4f5083",
"version" : "1.65.1"
}
},
{
"identity" : "gtm-session-fetcher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "3cdb78efb79b4a5383c3911488d8025bfc545b5e",
"version" : "4.3.0"
}
},
{
"identity" : "interop-ios-for-google-sdks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
"state" : {
"revision" : "2d12673670417654f08f5f90fdd62926dc3a2648",
"version" : "100.0.0"
}
},
{
"identity" : "keychainaccess",
"kind" : "remoteSourceControl",
Expand All @@ -19,6 +100,24 @@
"revision" : "e0c7eebc5a4465a3c4680764f26b7a61f567cdaf"
}
},
{
"identity" : "leveldb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/leveldb.git",
"state" : {
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1",
"version" : "1.22.5"
}
},
{
"identity" : "nanopb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/nanopb.git",
"state" : {
"revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1",
"version" : "2.30910.0"
}
},
{
"identity" : "panmodal",
"kind" : "remoteSourceControl",
Expand All @@ -37,6 +136,15 @@
"version" : "3.7.2"
}
},
{
"identity" : "promises",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/promises.git",
"state" : {
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac",
"version" : "2.4.0"
}
},
{
"identity" : "rusaint-ios",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -154,6 +262,15 @@
"version" : "1.4.1"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "ebc7251dd5b37f627c93698e4374084d98409633",
"version" : "1.28.2"
}
},
{
"identity" : "swift-sharing",
"kind" : "remoteSourceControl",
Expand Down
15 changes: 15 additions & 0 deletions Soomsil-USaint/Application/AppReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ struct AppReducer {
}

enum Action {
case checkMinimumVersion
case checkMinimumVersionResponse(Result<String, Error>)
case initialize
case initResponse(Result<(StudentInfo, TotalReportCard), Error>)
case backgroundTask
Expand All @@ -31,12 +33,25 @@ struct AppReducer {
}

@Dependency(\.localNotificationClient) var localNotificationClient
@Dependency(\.remoteConfigClient) var remoteConfigClient
@Dependency(\.gradeClient) var gradeClient
@Dependency(\.studentClient) var studentClient

var body: some Reducer<State, Action> {
Reduce { state, action in
switch action {
case .checkMinimumVersion:
return .run { send in
await send(.checkMinimumVersionResponse(Result {
return try await remoteConfigClient.getMinimumVersion()
}))
}
case .checkMinimumVersionResponse(.success(let minimumVersion)):
debugPrint("MinimumVersion at AppReducer - \(minimumVersion)")
return .send(.initialize)
case .checkMinimumVersionResponse(.failure(let error)):
debugPrint("Error at AppReducer - \(error)")
return .send(.initialize)
case .initialize:
return .run { send in
await send(.initResponse(Result {
Expand Down
2 changes: 1 addition & 1 deletion Soomsil-USaint/Application/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct AppView: View {
case .initial:
SplashView()
.onAppear {
store.send(.initialize)
store.send(.checkMinimumVersion)
}
case .loggedOut:
if let store = store.scope(state: \.loggedOut, action: \.login) {
Expand Down
10 changes: 10 additions & 0 deletions Soomsil-USaint/Application/Rusaint_iOSApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@ import SwiftUI
import BackgroundTasks

import ComposableArchitecture
import FirebaseCore
import Rusaint

class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
}

@main
struct Rusaint_iOSApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate

@Environment(\.scenePhase) var scenePhase

let store = Store(initialState: AppReducer.State()) { AppReducer() }
Expand Down
46 changes: 46 additions & 0 deletions Soomsil-USaint/Data/Client/Firebase/RemoteConfigClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// RemoteConfigClient.swift
// Soomsil-USaint
//
// Created by 정지혁 on 2/18/25.
//

import Foundation

import ComposableArchitecture
import FirebaseRemoteConfig

@DependencyClient
struct RemoteConfigClient {
private static let minimumVersionkey: String = "min_version_ios"

var getMinimumVersion: @Sendable () async throws -> String
}

extension DependencyValues {
var remoteConfigClient: RemoteConfigClient {
get { self[RemoteConfigClient.self] }
set { self[RemoteConfigClient.self] = newValue }
}
}

extension RemoteConfigClient: DependencyKey {
static let liveValue: RemoteConfigClient = Self(
getMinimumVersion: {
let remoteConfig = RemoteConfig.remoteConfig()
try await remoteConfig.fetchAndActivate()

let minimumVersion = remoteConfig[minimumVersionkey].stringValue
debugPrint(minimumVersion)
return minimumVersion
}
)

static let previewValue: RemoteConfigClient = Self(
getMinimumVersion: {
return "3.0.2"
}
)

static let testValue: RemoteConfigClient = previewValue
}
30 changes: 30 additions & 0 deletions Soomsil-USaint/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>AIzaSyDpHLpOch4gBX2fqS313wTrQH2IUzHmlg0</string>
<key>GCM_SENDER_ID</key>
<string>52701294141</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.yourssu.SaintKit</string>
<key>PROJECT_ID</key>
<string>soomsil-usaint</string>
<key>STORAGE_BUCKET</key>
<string>soomsil-usaint.firebasestorage.app</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:52701294141:ios:e6a52f5369e1afd0814454</string>
</dict>
</plist>