如何在不影响用户的情况下使用Firebase项目?

时间:2017-12-28 04:27:22

标签: ios firebase firebase-realtime-database firebase-storage

我希望能够在不影响当前用户的情况下使用我的应用。但是,我仍然希望使用当前的数据结构和存储中的文件。我想测试发布数据和查询数据,而无需用户看到这些操作。这样做的最佳方法是什么?

目前我考虑过在Firebase中创建另一个项目。我可以导出数据库的JSON,但我无法访问存储中的文件?我没有看到导出存储中所有文件的方法,所以我不确定如何继续。

更新

我不确定是否应删除此问题,似乎与this question重复。

2 个答案:

答案 0 :(得分:1)

强烈建议针对不同的环境(开发,测试,阶段,产品等)制作不同的项目。你不应该在生产中进行测试。

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

如果您正在使用iOS,则可以查看this questionthis Gistthis blog post

答案 1 :(得分:0)

查看documentation,您可以通过手动配置GoogleService-Info.plist来轻松完成此操作:

// 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"

您可以将其合并到AppDelegate中,如下所示:

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
}

如果翻转isDebug的值以确定加载了哪个版本的应用,则需要执行的操作。使用此方法还允许分析在两个版本的应用程序上工作。对于生产代码,只需删除isDebug和其他情况。

相关问题