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?










share|improve this question



























    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?










    share|improve this question

























      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?










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 22:32

























      asked Nov 9 at 18:21









      sgarza62

      2,36242449




      2,36242449






















          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.






          share|improve this answer




















            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
            );



            );













             

            draft saved


            draft discarded


















            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.






            share|improve this answer
























              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.






              share|improve this answer






















                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.






                share|improve this answer












                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 9 at 20:52









                ReyHaynes

                1,3271613




                1,3271613



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Use pre created SQLite database for Android project in kotlin

                    Darth Vader #20

                    Ondo