[Firebase] cocoaPod을 사용한 remoteConfig 연결 / splash / Firebase/RemoteConfig
2022. 5. 10. 18:48ㆍ🍏/Xcode
개발 환경 :
- macOS Monterey 12.3.1
- Xcode 13.3.1
- Firebase Version 9.0.0
pod init 후 작성
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Chat' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Chat
pod 'SnapKit', '~> 5.6.0'
# Add the pods for the Firebase products you want to use in your app
# For example, to use Firebase Authentication and Cloud Firestore
pod 'FirebaseAuth'
pod 'FirebaseFirestore'
pod 'Firebase/Core'
pod 'Firebase/RemoteConfig'
end
M1 chip cocoaPod error 해결 명령어
arch -x86_64 pod install
Firebase splash(매개변수)
- FirebaseRemoteConfig Import
import FirebaseRemoteConfig
ViewController.Swift
// MARK: - RemoteConfig
remoteConfig = RemoteConfig.remoteConfig()
let settings = RemoteConfigSettings()
settings.minimumFetchInterval = 10
remoteConfig.configSettings = settings
remoteConfig.setDefaults(fromPlist: "RemoteConfigDefaults")
remoteConfig.fetch { (status, error) -> Void in
if status == .success {
print("Config fetched!")
self.remoteConfig.activate { changed, error in
// ...
}
} else {
print("Config not fetched")
print("Error: \(error?.localizedDescription ?? "No error available.")")
}
self.displayWelcome()
}
func displayWelcome() {
let color = remoteConfig["splash_background"].stringValue // remote config key : value
let caps = remoteConfig["splash_message_caps"].boolValue
let message = remoteConfig["splash_message"].stringValue
if(caps){
let alert = UIAlertController(title: "Show Message", message: message, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "Confirm", style: UIAlertAction.Style.default, handler: {(action) in
exit(0)
}))
self.present(alert, animated: true, completion: nil)
}
self.view.backgroundColor = UIColor(hex: color!)
}
출처 :
'🍏 > Xcode' 카테고리의 다른 글
[Xcode] Swift Build System (0) | 2024.02.01 |
---|---|
nib와 bundle (1) | 2023.08.28 |
[Swift] Alamofire response parsing / Alamofire json parsing (0) | 2022.10.10 |
[Xcode] Development localization / 개발 현지화 (0) | 2022.10.06 |
[Xcode] ImageLiteral() / ios 이미지 코드에 등록 / ios image code / ios 글자를 이미지 처럼 / 코드에 image (0) | 2022.05.10 |