-3
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, GADInterstitialDelegate {
    
    //START OF CONFIGURATION

    static let BANNER_ADS_ON = true

how to implement to change the BANNER_ADS_ON in Firebase Remote Config

1 Answers1

0

Using Firebase Remote Config shouldn't be complex. Please have a read on Firebase's documentation and tutorial: https://firebase.google.com/docs/remote-config/use-config-ios#swift


To give you more idea, in your AppDelegate, you will do something like this:

private func setupRemoteConfig() {
    // Interval 1 day if prod. Otherwise 0.
    let interval: TimeInterval = ENVManager.currentEnv == .production ? (60 * 60 * 24 * 1) : 0
    
    let settings = RemoteConfigSettings()
    settings.minimumFetchInterval = interval
    
    let remoteConfig = RemoteConfig.remoteConfig()
    remoteConfig.configSettings = settings
    
    remoteConfig.fetch(withExpirationDuration: interval) { (status, error) in
        if status == .success {
            print("Config fetched!")
            remoteConfig.activate() { (error) in
                // ...
            }
        } else {
            print("Config not fetched")
            print("Error: \(error?.localizedDescription ?? "No error available.")")
        }
    }
}

and then to access your value, in your case it's BANNER_ADS_ON or whatever key you want, do it like this:

let configData = RemoteConfig.remoteConfig()["BANNER_ADS_ON"].stringValue
Glenn Posadas
  • 12,555
  • 6
  • 54
  • 95