react-native-branch-deep-linking-attribution
react-native-branch-deep-linking-attribution copied to clipboard
Feature: Move branch_key and branch_app_domain to the JS side
@jdee I've been making my rounds to the various React Native plugins with this request. It'd be great to move the branch_key
and branch_app_domain
that is put in the Info.plist
for iOS and that is put AndroidManifest.xml
for Android to the JS side.
Moving the keys to the JS side has several advantages:
-
We only have to put it in one place. This will reduce bugs (and issues for you guys!) and steps during the installation.
-
By using 12 Factor best practices, having it in the JS is very easy because we can generate one
env.js
file and have ALL of our JS filesimport
that file and grab keys like we needed. -
If changes to the underlying iOS or Android code is ever made, this protects that as it's agnostic to what happens under the hood.
For example, it could look like this:
import {
subscribe
setKey,
setAppDomain
} from 'react-native-branch';
import {
BRANCH_KEY,
BRANCH_APP_DOMAIN
} from '../../../env.js'; // this file is not in the repo!
export function init() {
setKey(BRANCH_KEY);
setAppDomain(BRANCH_APP_DOMAIN);
subscribe(bundle => {
console.log('bundle', bundle);
if (bundle && bundle.params) {
runAction(bundle.params);
}
});
}