react-native-branch-deep-linking-attribution icon indicating copy to clipboard operation
react-native-branch-deep-linking-attribution copied to clipboard

Feature: Move branch_key and branch_app_domain to the JS side

Open dwilt opened this issue 7 years ago • 14 comments

@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:

  1. We only have to put it in one place. This will reduce bugs (and issues for you guys!) and steps during the installation.

  2. 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 files import that file and grab keys like we needed.

  3. 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);
        }
    });
}

dwilt avatar Apr 12 '17 19:04 dwilt