Reputation: 2837
I need to be able to load different settings on my onCreate function based on production/staging, my app is a react native but I need to do this in my java file here is my current code
@Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Answers());
Fabric.with(this, new Crashlytics());
Intercom.initialize(this, "android_sdk-xxxx", "xxxx");
SoLoader.init(this, /* native exopackage */ false);
}
}
I would like to load different Intercom keys
Upvotes: 0
Views: 69
Reputation: 1172
In your gradle.properties
set the values for debug/staging/production
DEBUG_KEY=debug-key-val
STAGING_KEY=staging-key-val
PRODUCTION_KEY=production-key-val
Then add them to build config
android {
buildTypes {
debug {
buildConfigField "String", "MY_KEY", "\"${DEBUG_KEY}\""
}
staging {
buildConfigField "String", "MY_KEY", "\"${STAGING_KEY}\""
}
release {
buildConfigField "String", "MY_KEY", "\"${PRODUCTION_KEY}\""
}
}
}
Then use it as BuildConfig.MY_KEY
. By selecting different build config debug
, staging
or release
the corresponding value will be set in BuildConfig.MY_KEY
.
Upvotes: 2