Reputation: 4623
I'm building a project with Nativescript-Vue. I have standard a setup with Webpack.
I understand that i can pass different vars, using something like this:
tns build android --bundle --env.development --env.property=value
How can i "distinguish" between the two different platforms(emulator and a real device, they are both "development"), in order to pass different API url's?
Upvotes: 0
Views: 164
Reputation: 21908
You can do something like this,
if (isIOS) {
const description = String(NSString.stringWithUTF8String(NXGetLocalArchInfo()[0].description));
this.isSimulator = description.indexOf("x86") !== -1 || description.indexOf("i386") !== -1;
}
if (isAndroid) {
this.isSimulator = android.os.Build.FINGERPRINT.startsWith("generic")
|| android.os.Build.FINGERPRINT.startsWith("unknown")
|| android.os.Build.MODEL.indexOf("google_sdk") !== -1
|| android.os.Build.MODEL.indexOf("Emulator") !== -1
|| android.os.Build.MODEL.indexOf("Android SDK built for x86") !== -1
|| android.os.Build.MANUFACTURER.indexOf("Genymotion") !== -1
|| (android.os.Build.BRAND.startsWith("generic") && android.os.Build.DEVICE.startsWith("generic"))
|| android.os.Build.PRODUCT === "google_sdk";
}
The Android version is almost same as the one @Narendra linked in his answer but more of the NativeScript / JavaScript version.
Upvotes: 1