DoesData
DoesData

Reputation: 7047

How to work on Firebase project without impacting users?

I want to be able to work on my app without impacting my current users. However, I still want to work with the current data structure and files in storage. I want to test posting data and querying data without users seeing these actions. What is the best way to go about doing this?

Currently I thought about just making another project in Firebase. I can export the JSON for the database, but I won't be able to access the files in storage? I don't see a way to export all of the files in storage so I'm not exactly sure how to proceed.

Update

Not sure if I should delete this question at it appears to be a duplicate of this question.

Upvotes: 0

Views: 78

Answers (2)

DoesData
DoesData

Reputation: 7047

Looking at the documentation you can do this rather easily by manually configuring your GoogleService-Info.plist like this:

// Configure with manual options.
let secondaryOptions = FirebaseOptions(googleAppID: "1:27992087142:ios:2a4732a34787067a", gcmSenderID: "27992087142")
secondaryOptions.bundleID = "com.google.firebase.devrel.FiroptionConfiguration"
secondaryOptions.apiKey = "AIzaSyBicqfAZPvMgC7NZkjayUEsrepxuXzZDsk"
secondaryOptions.clientID = "27992087142-ola6qe637ulk8780vl8mo5vogegkm23n.apps.googleusercontent.com"
secondaryOptions.databaseURL = "https://myproject.firebaseio.com"
secondaryOptions.storageBucket = "myproject.appspot.com"

You can incorporate this into your AppDelegate like so:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    if !isDebug {
        print("setting config for release")
        let releaseOptions = FirebaseOptions(googleAppID: "1:27992087142:ios:2a4732a34787067a", gcmSenderID: "27992087142")
        releaseOptions.bundleID = "com.myProject"
        releaseOptions.apiKey = "AIzaSyBicqfAZPvMgC7NZkjayUEsrepxuXzZDsk"
        releaseOptions.clientID = "27992087142-ola6qe637ulk8780vl8mo5vogegkm23n.apps.googleusercontent.com"
        releaseOptions.databaseURL = "https://myproject.firebaseio.com"
        releaseOptions.storageBucket = "myproject.appspot.com"
        FirebaseApp.configure(options: releaseOptions)
    }
    else {
        print("setting config for debug")
        let debugOptions = FirebaseOptions(googleAppID: "DebugID", gcmSenderID: "DebugSender")
        debugOptions.bundleID = "com.myProjectDebug"
        debugOptions.apiKey = "Debug API key"
        debugOptions.clientID = "Debug Client ID
        debugOptions.databaseURL = "https://myprojectDebug.firebaseio.com"
        debugOptions.storageBucket = "myprojectDebug.appspot.com"
        FirebaseApp.configure(options: debugOptions)
    }
    return true
}

Then all you need to do if flip the value of isDebug to determine which version of the app is loaded. Using this method also allows for analytics to work on both versions of the app. For production code just remove isDebug and the else case.

Upvotes: 0

Doug Stevenson
Doug Stevenson

Reputation: 317750

It's strongly advised to have different projects for different environments (dev, test, stage, prod, etc). You should not be testing in production.

https://firebase.googleblog.com/2016/08/organizing-your-firebase-enabled-android-app-builds.html

If you're using iOS you can look at this question, this Gist, or this blog post.

Upvotes: 1

Related Questions