feat: Make react-native-config work with white labels #941
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
During build phase,
react-native-config
generates a.BuildConfig
class from the project.env
fileThen on runtime, it will try to reconstruct this classe name by querying its package name from app's resources using the following code
This would work only if the app's
packageId
andnamespace
are the sameBut since we implemented the new white label mechanism, those values can now be different. This is the case for the MaBulle version that has
io.cozy.flagship.mobile.mabulle
as package name butio.cozy.flagship.mobile
as namespaceIn the previous code, the resource would be searched in
getPackageName()
which would return thepackageId
but the resource would be stored in thenamespace
, sobuild_config_package
would not be foundThe result is that the app won't find any config value (i.e. Safetynet API key and Sentry auth token)
To fix that we add a new instruction in the
build.gradle
file to setbuild_config_package
in thepackageId
tooAs our white label mechanism always set
io.cozy.flagship.mobile
asnamespace
, so we use this value forbuild_config_package
Related commit: d08fd4b