Skip to content

[IDLE-000] 네트워크 연결확인 / 강제업데이트 / FireBase 크래쉬리틱스 추가 #65

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

Merged
merged 7 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public enum IdleInfoPlist {

"CFBundleDisplayName": "케어밋",

"CFBundleShortVersionString" : "1.0.0",

"NSAppTransportSecurity" : [
"NSAllowsArbitraryLoads" : true
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// TargetScripts.swift
// ConfigurationPlugin
//
// Created by choijunios on 9/14/24.
//

import Foundation
import ProjectDescription

// MARK: Firebase crashlytics

public extension TargetScript {

static let crashlyticsScript: TargetScript = .post(
script: """
ROOT_DIR=\(ProcessInfo.processInfo.environment["TUIST_ROOT_DIR"] ?? "")
"${ROOT_DIR}/Tuist/.build/checkouts/firebase-ios-sdk/Crashlytics/run"
""",
name: "Firebase Crashlytics",
inputPaths: [
"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}",
"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist",
"$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/GoogleService-Info.plist",
"$(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)",
],
basedOnDependencyAnalysis: false
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public extension ModuleDependency {
public static let FSCalendar: TargetDependency = .external(name: "FSCalendar")
public static let NaverMapSDKForSPM: TargetDependency = .external(name: "Junios.NMapSDKForSPM")
public static let KingFisher: TargetDependency = .external(name: "Kingfisher")
public static let FirebaseRemoteConfig: TargetDependency = .external(name: "FirebaseRemoteConfig")
public static let FirebaseCrashlytics: TargetDependency = .external(name: "FirebaseCrashlytics")
public static let FirebaseAnalytics: TargetDependency = .external(name: "FirebaseAnalytics")
}
}

5 changes: 4 additions & 1 deletion project/Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ let project = Project(
infoPlist: IdleInfoPlist.appDefault,
sources: ["Sources/**"],
resources: ["Resources/**"],
scripts: [
.crashlyticsScript
],
dependencies: [

// Presentation
Expand All @@ -39,7 +42,7 @@ let project = Project(
D.Data.ConcreteRepository,

// ThirdParty
D.ThirdParty.Swinject
D.ThirdParty.Swinject,
],
settings: .settings(
configurations: IdleConfiguration.appConfigurations
Expand Down
30 changes: 30 additions & 0 deletions project/Projects/App/Resources/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>AIzaSyB4eId4P8P3XlpHIVINfVpyB-pMQmqNxQM</string>
<key>GCM_SENDER_ID</key>
<string>740246202578</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.idle.caremeet</string>
<key>PROJECT_ID</key>
<string>swm-3idiots</string>
<key>STORAGE_BUCKET</key>
<string>swm-3idiots.appspot.com</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:740246202578:ios:d5e59f4f2116f92342250b</string>
</dict>
</plist>
6 changes: 4 additions & 2 deletions project/Projects/App/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ import UIKit
import AppTrackingTransparency
import AdSupport
import PresentationCore
import FirebaseCore

@main
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: { [weak self] in
self?.requestTrackingAuthorization()
})

// FireBase setting
FirebaseApp.configure()

return true
}

Expand Down
5 changes: 5 additions & 0 deletions project/Projects/App/Sources/DI/Assembly/DataAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,10 @@ public struct DataAssembly: Assembly {
container.register(RecruitmentPostRepository.self) { _ in
return DefaultRecruitmentPostRepository()
}

// MARK: RemoteConfig
container.register(RemoteConfigRepository.self) { _ in
return DefaultRemoteConfigRepository()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class RootCoordinator {
authUseCase: injector.resolve(AuthUseCase.self),
workerProfileUseCase: injector.resolve(WorkerProfileUseCase.self),
centerProfileUseCase: injector.resolve(CenterProfileUseCase.self),
userInfoLocalRepository: injector.resolve(UserInfoLocalRepository.self)
userInfoLocalRepository: injector.resolve(UserInfoLocalRepository.self),
remoteConfigRepository: injector.resolve(RemoteConfigRepository.self)
)

vc.bind(viewModel: vm)
Expand Down
58 changes: 58 additions & 0 deletions project/Projects/Data/ConcreteRepository/RemoteConfig/asd.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// asd.swift
// ConcreteRepository
//
// Created by choijunios on 9/13/24.
//

import Foundation
import RepositoryInterface

import RxSwift
import FirebaseRemoteConfig
import Entity

public class DefaultRemoteConfigRepository: RemoteConfigRepository {

private let remoteConfig = RemoteConfig.remoteConfig()
private let settings = RemoteConfigSettings()

public init() {
remoteConfig.configSettings = settings
}

public func fetchRemoteConfig() -> RxSwift.Single<Result<Bool, Error>> {

Single.create { [weak self] single in

self?.remoteConfig.fetch { status, error in

if status == .success {
self?.remoteConfig.activate()
single(.success(.success(true)))
} else {
single(.success(.success(false)))
}
}

return Disposables.create { }
}
}

public func getForceUpdateInfo() -> ForceUpdateInfo? {
let jsonData = remoteConfig["forceUpdate_iOS"].jsonValue

if let jsonData {

do {
let data = try JSONSerialization.data(withJSONObject: jsonData)
let decoded = try JSONDecoder().decode(ForceUpdateInfo.self, from: data)
return decoded
} catch {

return nil
}
}
return nil
}
}
4 changes: 0 additions & 4 deletions project/Projects/Data/DataSource/API/AuthAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ extension AuthAPI: BaseAPI {
}
}

public var validationType: ValidationType {
.successCodes
}

public var task: Task {
switch self {
case .startPhoneNumberAuth:
Expand Down
47 changes: 42 additions & 5 deletions project/Projects/Data/DataSource/Service/BaseNetworkService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,51 @@ public extension BaseNetworkService {
provider.rx
.request(api)
.catch { error in
if let moyaError = error as? MoyaError {

let moyaError = error as! MoyaError

// 재시도 실패 or 근본적인 에러(Ex 타임아웃, 네트워크 끊어짐)
if case let .underlying(error, response) = moyaError {

var response: Response?
// 리타리어 실패
if let afError = error.asAFError {

if case .requestRetryFailed = afError, let response {

return .error(
HTTPResponseException(response: response)
)
}
}

if case let .underlying(_, res) = moyaError { response = res }
if case let .statusCode(res) = moyaError { response = res }
if let response { return .error(HTTPResponseException(response: response)) }
// 근본적인 문제
if let urlError = error as? URLError {

var underlyingError: UnderLyingError!

switch urlError.code {
case .notConnectedToInternet:
underlyingError = .internetNotConnected
case .networkConnectionLost:
underlyingError = .networkConnectionLost
case .timedOut:
underlyingError = .timeout
default:
underlyingError = .unHandledError
}

return .error(underlyingError)
}
}

// HTTP통신 에러
if case let .statusCode(response) = moyaError {
return .error(
HTTPResponseException(response: response)
)
}

// 엣지 케이스
return .error(error)
}
}
Expand Down
3 changes: 2 additions & 1 deletion project/Projects/Data/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ let project = Project(
D.Data.DataSource,

// ThirdParty
D.ThirdParty.RxSwift
D.ThirdParty.RxSwift,
D.ThirdParty.FirebaseRemoteConfig
],
settings: .settings(
base: ["ENABLE_TESTABILITY": "YES"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ public class DefaultRecruitmentPostUseCase: RecruitmentPostUseCase {
requestCnt: postCount
)
case .thirdParty:
return .just(.failure(.undefinedError))
// Presentation에서 에초에 호출하지 않음
return .just(.failure(.undefinedCode))
}
}

Expand Down
14 changes: 14 additions & 0 deletions project/Projects/Domain/Entity/Config/ForceUpdateInfo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// ForceUpdateInfo.swift
// Entity
//
// Created by choijunios on 9/13/24.
//

import Foundation

public struct ForceUpdateInfo: Decodable {
public let minVersion: String
public let marketUrl: String
public let noticeMsg: String
}
27 changes: 17 additions & 10 deletions project/Projects/Domain/Entity/Error/DomainError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public enum DomainError: Error {
public enum DomainError: Error, Equatable {

// API
case invalidParameter
Expand Down Expand Up @@ -58,10 +58,8 @@ public enum DomainError: Error {

// undefinedError
case undefinedCode
case undefinedError

// Not Implemented
case notImplemented
case undelyingError(error: UnderLyingError)

public init(code: String) {
switch code {
Expand Down Expand Up @@ -123,7 +121,7 @@ public enum DomainError: Error {
self = .geoCodingFailure

default:
self = .undefinedError
self = .undefinedCode
}
}

Expand Down Expand Up @@ -199,11 +197,20 @@ public enum DomainError: Error {
case .geoCodingFailure:
return "입력된 주소로 지리 정보를 찾을 수 없습니다. 주소를 다시 확인해주세요."

case .undefinedCode, .undefinedError:
return "예기치 않은 오류가 발생했습니다. 잠시 후 다시 시도해주세요."

case .notImplemented:
return "아직 개발되지 않은 기능입니다."
case .undefinedCode:
return "처리되지 않은 HTTP코드입니다."

case .undelyingError(let underlyingError):
switch underlyingError {
case .internetNotConnected:
return "인터넷이 연결되지 않았습니다."
case .timeout:
return "요청시간을 초과했습니다."
case .networkConnectionLost:
return "연결상태가 변경됬습니다."
case .unHandledError:
return "알 수 없는 문제가 발생했습니다."
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Entity.swift
// ConcreteUseCase
//
// Created by choijunios on 9/13/24.
//

import Foundation

public enum UnderLyingError: Error {

case internetNotConnected
case timeout
case networkConnectionLost
case unHandledError
}
4 changes: 3 additions & 1 deletion project/Projects/Domain/Entity/VO/AlertContentVO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ public struct DefaultAlertContentVO {

public let title: String
public let message: String
public let dismissButtonLabelText: String
public let onDismiss: (() -> ())?

public init(title: String, message: String, onDismiss: (() -> ())? = nil) {
public init(title: String, message: String, dismissButtonLabelText: String = "닫기", onDismiss: (() -> ())? = nil) {
self.title = title
self.message = message
self.dismissButtonLabelText = dismissButtonLabelText
self.onDismiss = onDismiss
}

Expand Down
Loading
Loading