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,37242449
2,37242449
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 .gitignored.
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 |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
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 .gitignored.
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 .gitignored.
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 .gitignored.
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 .gitignored.
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,3371613
1,3371613
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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