Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Branch.io: how to switch between live and test environment in iOS

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![screenshot of branch config in plist file

like image 947
Chenglu Avatar asked Jun 16 '16 22:06

Chenglu


People also ask

How do I test a branch event?

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.

Where is my branch test key?

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.


1 Answers

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
like image 165
Alex Bauer Avatar answered Oct 06 '22 22:10

Alex Bauer