Skip to content

Commit 6c1e28d

Browse files
authored
Merge pull request #251 from Runnect/#206
[Feat] #206 - remote config 추가했습니다
2 parents bf46e56 + 9f7a1f1 commit 6c1e28d

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

Runnect-iOS/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ target 'Runnect-iOS' do
2222
pod 'FirebaseAnalytics'
2323
pod 'FirebaseAuth'
2424
pod 'FirebaseFirestore'
25-
25+
pod 'Firebase/RemoteConfig'
2626

2727

2828
end

Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
232686362B03AF4400675A17 /* NetworkProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 232686352B03AF4400675A17 /* NetworkProvider.swift */; };
11+
23628DDE2B6BCB9C00894B18 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 23628DDD2B6BCB9C00894B18 /* GoogleService-Info.plist */; };
1112
23EE06C12AC1AD5200CB3FF8 /* LocationSelectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23EE06C02AC1AD5200CB3FF8 /* LocationSelectView.swift */; };
1213
23EE06C52AC1AE1900CB3FF8 /* BaseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23EE06C42AC1AE1900CB3FF8 /* BaseView.swift */; };
1314
23EE06C92AC1DED100CB3FF8 /* GesturePublisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23EE06C82AC1DED100CB3FF8 /* GesturePublisher.swift */; };
@@ -21,7 +22,6 @@
2122
712DB0702B443ACC0013FD79 /* GAEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 712DB06F2B443ACC0013FD79 /* GAEvent.swift */; };
2223
712F661D2A7B7BAB00D9539B /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 712F661C2A7B7BAB00D9539B /* Config.swift */; };
2324
7136BF8A2AF921A900679364 /* CustomBottomSheetVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7136BF892AF921A900679364 /* CustomBottomSheetVC.swift */; };
24-
713A98F02B29DD9900189B3C /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 713A98EF2B29DD9900189B3C /* GoogleService-Info.plist */; };
2525
715D36E82B2CC64000CAA9D6 /* MyUploadedCourseResponseDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 715D36E72B2CC64000CAA9D6 /* MyUploadedCourseResponseDto.swift */; };
2626
717916DA2B13613B009CEF97 /* MarathonListResponseDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 717916D92B13613B009CEF97 /* MarathonListResponseDto.swift */; };
2727
71802C5C2B3364C2008DBCEE /* CourseDetailScrapCountDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71802C5B2B3364C2008DBCEE /* CourseDetailScrapCountDto.swift */; };
@@ -180,6 +180,7 @@
180180

181181
/* Begin PBXFileReference section */
182182
232686352B03AF4400675A17 /* NetworkProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProvider.swift; sourceTree = "<group>"; };
183+
23628DDD2B6BCB9C00894B18 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
183184
23EE06C02AC1AD5200CB3FF8 /* LocationSelectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationSelectView.swift; sourceTree = "<group>"; };
184185
23EE06C42AC1AE1900CB3FF8 /* BaseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseView.swift; sourceTree = "<group>"; };
185186
23EE06C82AC1DED100CB3FF8 /* GesturePublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GesturePublisher.swift; sourceTree = "<group>"; };
@@ -194,7 +195,6 @@
194195
712DB06F2B443ACC0013FD79 /* GAEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GAEvent.swift; sourceTree = "<group>"; };
195196
712F661C2A7B7BAB00D9539B /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
196197
7136BF892AF921A900679364 /* CustomBottomSheetVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBottomSheetVC.swift; sourceTree = "<group>"; };
197-
713A98EF2B29DD9900189B3C /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
198198
715D36E72B2CC64000CAA9D6 /* MyUploadedCourseResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyUploadedCourseResponseDto.swift; sourceTree = "<group>"; };
199199
717916D92B13613B009CEF97 /* MarathonListResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarathonListResponseDto.swift; sourceTree = "<group>"; };
200200
71802C5B2B3364C2008DBCEE /* CourseDetailScrapCountDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDetailScrapCountDto.swift; sourceTree = "<group>"; };
@@ -869,7 +869,7 @@
869869
CE6655A9295D7FAA00C64E12 /* Network */,
870870
CE6655A8295D7F7D00C64E12 /* Presentation */,
871871
CE4545D6295D7AF5003201E1 /* Info.plist */,
872-
713A98EF2B29DD9900189B3C /* GoogleService-Info.plist */,
872+
23628DDD2B6BCB9C00894B18 /* GoogleService-Info.plist */,
873873
);
874874
path = "Runnect-iOS";
875875
sourceTree = "<group>";
@@ -1334,7 +1334,7 @@
13341334
files = (
13351335
CE665615295D989A00C64E12 /* .swiftlint.yml in Resources */,
13361336
CE17F0342961BEF800E1DED0 /* Pretendard-Bold.otf in Resources */,
1337-
713A98F02B29DD9900189B3C /* GoogleService-Info.plist in Resources */,
1337+
23628DDE2B6BCB9C00894B18 /* GoogleService-Info.plist in Resources */,
13381338
CE17F0352961BEF800E1DED0 /* Pretendard-SemiBold.otf in Resources */,
13391339
CE17F0332961BEF800E1DED0 /* Pretendard-Medium.otf in Resources */,
13401340
CE6655BF295D82E200C64E12 /* .gitkeep in Resources */,

Runnect-iOS/Runnect-iOS/Global/Supports/AppDelegate.swift

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import KakaoSDKCommon
1313
import FirebaseCore
1414
import FirebaseFirestore
1515
import FirebaseAuth
16+
import FirebaseRemoteConfig
1617

1718
@main
1819
class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -38,6 +39,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3839
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
3940

4041
FirebaseApp.configure()
42+
setRemoteConfig()
43+
4144
NMFAuthManager.shared().clientId = Config.naverMapClientId
4245
KakaoSDK.initSDK(appKey: Config.kakaoNativeAppKey)
4346

@@ -58,3 +61,58 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5861
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
5962
}
6063
}
64+
65+
extension AppDelegate {
66+
func setRemoteConfig() {
67+
let remoteConfig = RemoteConfig.remoteConfig()
68+
let settings = RemoteConfigSettings()
69+
70+
/// 개발 중에는 0으로 설정
71+
settings.minimumFetchInterval = 86400 // 24hour
72+
remoteConfig.configSettings = settings
73+
74+
remoteConfig.fetch() { (status, error) -> Void in
75+
if status == .success {
76+
remoteConfig.activate() { (changed, error) in
77+
guard let info = Bundle.main.infoDictionary,
78+
let currentVersion = info["CFBundleShortVersionString"] as? String,
79+
let identifier = info["CFBundleIdentifier"] as? String,
80+
let storeVersion = remoteConfig["iOS_current_market_version"].stringValue
81+
else { return }
82+
83+
if currentVersion.compare(storeVersion, options: .numeric) == .orderedAscending {
84+
self.showUpdateAlert()
85+
}
86+
}
87+
} else {
88+
print("Error: \(error?.localizedDescription ?? "No error available.")")
89+
}
90+
}
91+
}
92+
93+
func showUpdateAlert() {
94+
DispatchQueue.main.sync {
95+
let alert = UIAlertController(
96+
title: "업데이트 알림",
97+
message: "새로운 기능이 추가된 'Runnect'의 최신 버전을 만나보세요!\n지금 바로 업데이트하고 개선된 사용자 경험을 즐겨보세요.",
98+
preferredStyle: .alert
99+
)
100+
101+
let updateAction = UIAlertAction(title: "업데이트 링크", style: .default) { _ in
102+
let url = "itms-apps://itunes.apple.com/app/1663884202"
103+
if let url = URL(string: url), UIApplication.shared.canOpenURL(url) {
104+
if #available(iOS 13.0, *) {
105+
UIApplication.shared.open(url, options: [:], completionHandler: nil)
106+
} else {
107+
UIApplication.shared.openURL(url)
108+
}
109+
}
110+
}
111+
112+
alert.addAction(updateAction)
113+
if let vc = UIApplication.shared.keyWindow?.rootViewController {
114+
vc.present(alert, animated: true, completion: nil)
115+
}
116+
}
117+
}
118+
}

0 commit comments

Comments
 (0)