feat(branch): add support for test environments #229
+168
−82
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.
Why
Branch has a handy test mode that lets developers test their implementation in a sandbox, preventing data pollution in the
live
environment. At the moment this config plugin does not support the test environment feature.iOS docs
Android docs
How
I introduced this feature into the config plugin by expanding the config plugin parameters to accept some new values:
testApiKey
(string): the test API key to be used when the test environment is enabledenableTestEnvironment
(boolean): setting this totrue
will enable the usage of the test environment.Enabling the test environment varies between platforms:
branch_test_environment
value into the generatedinfo.plist
, we can assert whether this value istrue
from theapplicationDidFinishLaunchWithOptions
(inside our Swift delegate) and call the appropriate SDK's mechanism to enable the test environment:RNBranch.useTestInstance()
io.branch.sdk.TestMode
.Considerations / Help Needed
Part of this PR depends on some updated types in the official
expo/config-types
. Specifically, theExpoConfig
type supports abranch.apiKey
field underneath theconfig.ios
andconfig.android
, and this config-plugin currently makes use of those values.In an ideal world, I think the global
ExpoConfig
should have nothing that deals with Branch. It just... doesn't make sense? If this sentiment is shared between other maintainers, I'd be happy to completely kill those values fromExpoConfig
and make the necessary changes in this PR to only take in options from the config-plugin itself.Regardless, I have opened a PR in the
expo
repo to update theExpoConfig
type to accept thetestApiKey
andenableTestEnvironment
parameters: expo/expo#28084What I'm confused about is how would these PRs be orchestrated to work together? Would we have to first merge the main repo PR and only then update the config plugin here? I'll wait for someone to chime in on this, as I'm a beginner in multi-repo contributions 😂
Test Plan
enableBranchTestEnvironment
functions.