As Branch said in its docs:
For more advanced implementations, you may want to specify keys for both Test and Live environments (for example, if you are building a custom switch to automatically select the correct key depending on compiler schemes).
Open your Info.plist file in Xcode, change the branch_key entry to a Dictionary, and create two subentries for your keys:
My question is: How do I build a custom switch to automatically select the correct key depending on compiler schemes? I understand I might use #if DEBUG to define the environment, but I don't understand is where do I tell branch which key it should use? Or branch will simply detect it automatically?
Thank you so much
Test Your Branch Integrationvalidate in your MainActivity's onStart(). Check your ADB Logcat to make sure all the SDK Integration tests pass. Make sure to comment out or remove IntegrationValidator. validate in your production build.
Obtain your Branch live and test keys from the Branch Dashboard: See the Account Settings page in the Branch Dashboard to find your Branch live and test keys. Select "Live" or "Test" at the upper left to switch keys. Perform basic integration of the react-native-branch SDK in your app.
Alex from Branch.io here: #if DEBUG
is the best, approach, and you actually just need to switch out your singleton call. Instead of
let branch: Branch = Branch.getInstance(); // Swift
Branch *branch = [Branch getInstance]; // Objective C
you'll use
let branch: Branch = Branch.getTestInstance(); // Swift
Branch *branch = [Branch getTestInstance]; // Objective C
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With