Testflight vs App store - detection from within app


#1

I have an ionic2 ios app which connects to backend.

There are two backend servers 1 staging and 2 production.

I want to use different URL to connect to backend based on from where the app is running. For example, if the user is running the app from testflight then it should use staging URL and connect to staging backend. If the app is running from app store installed version then it should use production URL and connect to production backend.

For this I want to detect from where the app is running in my ionic2 code. Any way to achieve this?

Thanks


#2

I can’t rally help with your specific questions, but wouldn’t it be also possible to build two different versions of the app and then push the one out via Testflight, and upload the other to the App Store? Would have to also have the additional benefit of being able to install both apps at the same time.


#3

I can tell how we deal with that problem in our company.
We not only use ionic to create our apps we also code real native code. On the native side you can detect if the app was downloaded by Test flight. If yes our apps shows the user the option to change the endpoints to prod or dev.

And you can also build a version with prod or development mode so Cordova can check if you running a prod or development version of your app.

DeviceMeta plugin is the name of the Cordova plugin I remember


#4

Interesting question, I would like to know too :wink:

Maybe?


#5

Here is a specialized plugin for detecting if the app came from store or TestFlight(+XCode):


#6

I asked a cordovs developer in my team and he also send me this plugin a minute ago :slight_smile:


#7

@Sujan12 Thanks for your response. So far I have been generating two different builds. However, it would be really awesome to have just one build which can be first tested using testflight and then then same build can be submitted to App store review WITHOUT needing any code change.


#8

@LoLStats Thanks. I will try it out in next couple of days.


#9

After you test, could you post the results here @brijeshamin?

I’m agree with you, would be cool to be able to handle that without having to increment the versionsnumber (“one for test, next for prod etc.”)


#10

@reedrichards sure I will update the thread with the results. Cheers.


#11

@reedrichards If I get time, I will try following as well,

cordova.plugins.DeviceMeta.getDeviceMeta(function(result){
   // result.debug - Whether App is in debug mode
   // result.networkProvider - Network provider name
   // result.ip - IP Address from device
   // result.manufacturer - Device manufacturer
});

This was on stackoverflow link that you suggested.
Thanks.