Check if build was sideloaded or downloaded from App/Play Store
up vote
1
down vote
favorite
React Native uses __DEV__
internally to check whether an app is a dev or release build.
We use that to determine whether we should point to our staging or production environments.
_host = (__DEV__) ? 'https://staging-api.foo-app.com' : 'https://api.foo-app.com';
if (Platform.OS === 'ios')
deploymentKey = (__DEV__) // iOS
? '5eCkg3JX3aip-D_a77eea5c3-0MXihVlUTZ4yy45a-432a-b73e-0a844d8b8310' // Staging
: 'zGxOja-Yhchs87eea5c3-0d5a-432aQriLlV17gI-sdj55-b73e-0a844d8b8310'; // Production
else
deploymentKey = (__DEV__) // Android
? 'vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310' // Staging
: '8DclNAKdcQkKlQDL77eea5c3-0d5a-432aslW1SeS6sDMo-b73e-0a844d8b8310'; // Production
The problem is that __DEV__
evaluates to false
for any builds sideloaded to a device from XCode and Android Studio. So, to test on a device, we do this in a few places:
// _host = (__DEV__) ? 'https://staging-api.foo-app.com' : 'https://api.foo-app.com';
_host = 'https://staging-api.foo-app.com';
How can we determine if an app is sideloaded vs downloaded from the App Store or Play Store?
react-native production-environment sideloading test-environments
add a comment |
up vote
1
down vote
favorite
React Native uses __DEV__
internally to check whether an app is a dev or release build.
We use that to determine whether we should point to our staging or production environments.
_host = (__DEV__) ? 'https://staging-api.foo-app.com' : 'https://api.foo-app.com';
if (Platform.OS === 'ios')
deploymentKey = (__DEV__) // iOS
? '5eCkg3JX3aip-D_a77eea5c3-0MXihVlUTZ4yy45a-432a-b73e-0a844d8b8310' // Staging
: 'zGxOja-Yhchs87eea5c3-0d5a-432aQriLlV17gI-sdj55-b73e-0a844d8b8310'; // Production
else
deploymentKey = (__DEV__) // Android
? 'vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310' // Staging
: '8DclNAKdcQkKlQDL77eea5c3-0d5a-432aslW1SeS6sDMo-b73e-0a844d8b8310'; // Production
The problem is that __DEV__
evaluates to false
for any builds sideloaded to a device from XCode and Android Studio. So, to test on a device, we do this in a few places:
// _host = (__DEV__) ? 'https://staging-api.foo-app.com' : 'https://api.foo-app.com';
_host = 'https://staging-api.foo-app.com';
How can we determine if an app is sideloaded vs downloaded from the App Store or Play Store?
react-native production-environment sideloading test-environments
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
React Native uses __DEV__
internally to check whether an app is a dev or release build.
We use that to determine whether we should point to our staging or production environments.
_host = (__DEV__) ? 'https://staging-api.foo-app.com' : 'https://api.foo-app.com';
if (Platform.OS === 'ios')
deploymentKey = (__DEV__) // iOS
? '5eCkg3JX3aip-D_a77eea5c3-0MXihVlUTZ4yy45a-432a-b73e-0a844d8b8310' // Staging
: 'zGxOja-Yhchs87eea5c3-0d5a-432aQriLlV17gI-sdj55-b73e-0a844d8b8310'; // Production
else
deploymentKey = (__DEV__) // Android
? 'vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310' // Staging
: '8DclNAKdcQkKlQDL77eea5c3-0d5a-432aslW1SeS6sDMo-b73e-0a844d8b8310'; // Production
The problem is that __DEV__
evaluates to false
for any builds sideloaded to a device from XCode and Android Studio. So, to test on a device, we do this in a few places:
// _host = (__DEV__) ? 'https://staging-api.foo-app.com' : 'https://api.foo-app.com';
_host = 'https://staging-api.foo-app.com';
How can we determine if an app is sideloaded vs downloaded from the App Store or Play Store?
react-native production-environment sideloading test-environments
React Native uses __DEV__
internally to check whether an app is a dev or release build.
We use that to determine whether we should point to our staging or production environments.
_host = (__DEV__) ? 'https://staging-api.foo-app.com' : 'https://api.foo-app.com';
if (Platform.OS === 'ios')
deploymentKey = (__DEV__) // iOS
? '5eCkg3JX3aip-D_a77eea5c3-0MXihVlUTZ4yy45a-432a-b73e-0a844d8b8310' // Staging
: 'zGxOja-Yhchs87eea5c3-0d5a-432aQriLlV17gI-sdj55-b73e-0a844d8b8310'; // Production
else
deploymentKey = (__DEV__) // Android
? 'vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310' // Staging
: '8DclNAKdcQkKlQDL77eea5c3-0d5a-432aslW1SeS6sDMo-b73e-0a844d8b8310'; // Production
The problem is that __DEV__
evaluates to false
for any builds sideloaded to a device from XCode and Android Studio. So, to test on a device, we do this in a few places:
// _host = (__DEV__) ? 'https://staging-api.foo-app.com' : 'https://api.foo-app.com';
_host = 'https://staging-api.foo-app.com';
How can we determine if an app is sideloaded vs downloaded from the App Store or Play Store?
react-native production-environment sideloading test-environments
react-native production-environment sideloading test-environments
edited Nov 9 at 22:32
asked Nov 9 at 18:21
sgarza62
2,36242449
2,36242449
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Instead of having keys and data that switches based on __DEV__
...might I suggest using various .env
files using a, much safer, 12-factor approach with react-native-config.
This way you can have deployment keys and environment based variables within files that can be .gitignore
d.
You can have something like:
.env (Staging)
HOST=https://staging-api.foo-app.com
DEPLOYMENT_KEY_IOS=5eCkg3JX3aip-D_a77eea5c3-0MXihVlUTZ4yy45a-432a-b73e-0a844d8b8310
DEPLOYMENT_KEY_ANDROID=vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310
.env.production (Production)
HOST=https://api.foo-app.com
DEPLOYMENT_KEY_IOS=vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310
DEPLOYMENT_KEY_ANDROID=8DclNAKdcQkKlQDL77eea5c3-0d5a-432aslW1SeS6sDMo-b73e-0a844d8b8310
react-native-config instructions should be clear enough on how you'd use each file based off build type.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Instead of having keys and data that switches based on __DEV__
...might I suggest using various .env
files using a, much safer, 12-factor approach with react-native-config.
This way you can have deployment keys and environment based variables within files that can be .gitignore
d.
You can have something like:
.env (Staging)
HOST=https://staging-api.foo-app.com
DEPLOYMENT_KEY_IOS=5eCkg3JX3aip-D_a77eea5c3-0MXihVlUTZ4yy45a-432a-b73e-0a844d8b8310
DEPLOYMENT_KEY_ANDROID=vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310
.env.production (Production)
HOST=https://api.foo-app.com
DEPLOYMENT_KEY_IOS=vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310
DEPLOYMENT_KEY_ANDROID=8DclNAKdcQkKlQDL77eea5c3-0d5a-432aslW1SeS6sDMo-b73e-0a844d8b8310
react-native-config instructions should be clear enough on how you'd use each file based off build type.
add a comment |
up vote
0
down vote
Instead of having keys and data that switches based on __DEV__
...might I suggest using various .env
files using a, much safer, 12-factor approach with react-native-config.
This way you can have deployment keys and environment based variables within files that can be .gitignore
d.
You can have something like:
.env (Staging)
HOST=https://staging-api.foo-app.com
DEPLOYMENT_KEY_IOS=5eCkg3JX3aip-D_a77eea5c3-0MXihVlUTZ4yy45a-432a-b73e-0a844d8b8310
DEPLOYMENT_KEY_ANDROID=vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310
.env.production (Production)
HOST=https://api.foo-app.com
DEPLOYMENT_KEY_IOS=vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310
DEPLOYMENT_KEY_ANDROID=8DclNAKdcQkKlQDL77eea5c3-0d5a-432aslW1SeS6sDMo-b73e-0a844d8b8310
react-native-config instructions should be clear enough on how you'd use each file based off build type.
add a comment |
up vote
0
down vote
up vote
0
down vote
Instead of having keys and data that switches based on __DEV__
...might I suggest using various .env
files using a, much safer, 12-factor approach with react-native-config.
This way you can have deployment keys and environment based variables within files that can be .gitignore
d.
You can have something like:
.env (Staging)
HOST=https://staging-api.foo-app.com
DEPLOYMENT_KEY_IOS=5eCkg3JX3aip-D_a77eea5c3-0MXihVlUTZ4yy45a-432a-b73e-0a844d8b8310
DEPLOYMENT_KEY_ANDROID=vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310
.env.production (Production)
HOST=https://api.foo-app.com
DEPLOYMENT_KEY_IOS=vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310
DEPLOYMENT_KEY_ANDROID=8DclNAKdcQkKlQDL77eea5c3-0d5a-432aslW1SeS6sDMo-b73e-0a844d8b8310
react-native-config instructions should be clear enough on how you'd use each file based off build type.
Instead of having keys and data that switches based on __DEV__
...might I suggest using various .env
files using a, much safer, 12-factor approach with react-native-config.
This way you can have deployment keys and environment based variables within files that can be .gitignore
d.
You can have something like:
.env (Staging)
HOST=https://staging-api.foo-app.com
DEPLOYMENT_KEY_IOS=5eCkg3JX3aip-D_a77eea5c3-0MXihVlUTZ4yy45a-432a-b73e-0a844d8b8310
DEPLOYMENT_KEY_ANDROID=vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310
.env.production (Production)
HOST=https://api.foo-app.com
DEPLOYMENT_KEY_IOS=vrrKTaq08Hid77eea5c3-0d5a-432aDhXbdI8-G9CnWmqc-b73e-0a844d8b8310
DEPLOYMENT_KEY_ANDROID=8DclNAKdcQkKlQDL77eea5c3-0d5a-432aslW1SeS6sDMo-b73e-0a844d8b8310
react-native-config instructions should be clear enough on how you'd use each file based off build type.
answered Nov 9 at 20:52
ReyHaynes
1,3271613
1,3271613
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231355%2fcheck-if-build-was-sideloaded-or-downloaded-from-app-play-store%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown