In our mission to support releasing software with confidence, we've added the ability to store and switch between multiple LaunchDarkly projects on our Android and iOS clients. You now have first-class support from our SDKs for flags used across multiple projects. For example, if you have an app that depends on shared backend services maintained by other teams, you might need to maintain the flags in separate projects but use flags from these projects within the app. As with previous SDK releases, the client can react to feature flag updates in real time for all subscribed environments. This new feature does not represent a breaking API change, and developers will not need to change the way they interface with either SDK.
To get started with this exciting new part of our SDK here's an Android example. Let's assume in this scenario we have a mobile app that depends on a common platform shared by other applications. First we need to add the mobile keys for other related projects to our configuration object, and our SDK will listen to flag updates for all subscribed projects in the background.
Map<string, string> otherMobileKeys = new HashMap<string, string>(); otherKeys.put("platform", "PLATFORM_MOBILE_KEY"); LDConfig ldConfig = new LDConfig.Builder() .setMobileKey("APP_MOBILE_KEY") .setSecondaryMobileKeys(otherKeys); .build(); </string,></string,>
Once the client is initialized, you only need to call one method to get access to the client instance for the project of your choice.
LDClient platformInstance = LDClient.getForMobileKey("platform"); platformInstance.boolVariation("platform-specific-flag", false);
We hope this addition to our Android and iOS SDKs empowers you to build new and exciting products and launch fearlessly! For more information see our documentation on multiple environments for Android.