Skip to content

Commit

Permalink
feat(mobile): add configurable build time var
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Froment <sfroment42@gmail.com>
  • Loading branch information
sfroment committed Feb 4, 2019
1 parent 7fe6a10 commit 3d888fc
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 3 deletions.
13 changes: 13 additions & 0 deletions client/react-native/android/app/build.gradle
Expand Up @@ -90,6 +90,16 @@ project.ext.react = [

apply from: "../../node_modules/react-native/react.gradle"


project.ext.envConfigFiles = [
debug: ".env",
release: ".env",
anothercustombuild: ".env",
]

apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"


/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
Expand Down Expand Up @@ -123,6 +133,8 @@ android {
versionCode 1
versionName "1.0"

resValue "string", "build_config_package", "chat.berty.main"

ndk {
abiFilters "armeabi-v7a", "x86"
}
Expand Down Expand Up @@ -204,6 +216,7 @@ android {
}

dependencies {
compile project(':react-native-config')
compile project(':react-native-dev-menu')
compile project(':instabug-reactnative')
compile project(':lottie-react-native')
Expand Down
Expand Up @@ -3,6 +3,7 @@
import android.app.Application;

import com.facebook.react.ReactApplication;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import com.zoontek.rndevmenu.RNDevMenuPackage;
import com.instabug.reactlibrary.RNInstabugReactnativePackage;
import com.airbnb.android.react.lottie.LottiePackage;
Expand Down Expand Up @@ -49,9 +50,10 @@ protected List<ReactPackage> getPackages() {
new CorePackage(),
new ImagePickerPackage(),
new MainReactPackage(),
new ReactNativeConfigPackage(),
new RNDevMenuPackage(),
new RNInstabugReactnativePackage.Builder("YOUR_ANDROID_APPLICATION_TOKEN",MainApplication.this)
.setInvocationEvent("shake")
new RNInstabugReactnativePackage.Builder(BuildConfig.INSTABUG_TOKEN,MainApplication.this)
.setInvocationEvent(BuildConfig.DEBUG ? "none" : "shake")
.setPrimaryColor("#1D82DC")
.setFloatingEdge("left")
.setFloatingButtonOffsetFromTop(250)
Expand Down
2 changes: 2 additions & 0 deletions client/react-native/android/settings.gradle
@@ -1,4 +1,6 @@
rootProject.name = 'Berty'
include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')
include ':react-native-dev-menu'
project(':react-native-dev-menu').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-dev-menu/android')
include ':instabug-reactnative'
Expand Down
4 changes: 3 additions & 1 deletion client/react-native/common/components/App.js
Expand Up @@ -13,6 +13,8 @@ import ReactNativeLanguages from 'react-native-languages'
import i18n from '../i18n'
import Instabug from 'instabug-reactnative';
import { btoa } from 'b64-lite'
import Config from 'react-native-config'


export default class App extends PureComponent {
state = {
Expand All @@ -31,7 +33,7 @@ export default class App extends PureComponent {

if (Platform.OS === 'ios') {
Instabug.startWithToken(
"IOS_TOKEN",
Config.INSTABUG_TOKEN,
[__DEV__ ? Instabug.invocationEvent.none : Instabug.invocationEvent.shake],
)
}
Expand Down
91 changes: 91 additions & 0 deletions client/react-native/ios/Berty.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/react-native/package.json
Expand Up @@ -33,6 +33,7 @@
"react-native": "^0.57.6",
"react-native-camera": "^1.4.3",
"react-native-collapsible": "^1.3.0",
"react-native-config": "^0.11.7",
"react-native-dev-menu": "^2.0.1",
"react-native-device-info": "^0.24.3",
"react-native-elements": "^1.0.0-beta7",
Expand Down
4 changes: 4 additions & 0 deletions client/react-native/yarn.lock
Expand Up @@ -5167,6 +5167,10 @@ react-native-collapsible@^1.3.0:
dependencies:
prop-types "^15.6.2"

react-native-config@^0.11.7:
version "0.11.7"
resolved "https://registry.yarnpkg.com/react-native-config/-/react-native-config-0.11.7.tgz#a2b323f2ecd76a4df88cbb6bc86eaa2ef9febee7"

react-native-dev-menu@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/react-native-dev-menu/-/react-native-dev-menu-2.0.1.tgz#8a54ab04532af26e2cbbe86bd41d8ce390fe2a04"
Expand Down

0 comments on commit 3d888fc

Please sign in to comment.