I'm developing an application, where it will have a paid (full) version and a free (lite) version.
In another application developed for Android it is possible to manage this easily with flavors (productFlavors
), where I can configure the replacement of any part of the application. For example: I can configure an applicationId and flag boolean PAID_VERSION
, for each application as follows:
productFlavors {
free {
applicationId 'com.mycompany.myapp.free'
buildConfigField "boolean", "PAID_VERSION", "false"
}
paid {
applicationId 'com.mycompany.myapp.paid'
buildConfigField "boolean", "PAID_VERSION", "true"
}
}
And in the code I can check the PAID_VERSION
flag of the following way:
boolean b = BuildConfig.PAID_VERSION;
And if I want to change the icon and application name by version I should specify in the packages (applicationId
) of each flavor the specific icon replacing the default, for example:
String resource application name:
Free path: /free/res/values/strings.xml
<resources>
<string name="app_name">My App - Free</string>
</resources>
Paid path: /paid/res/values/strings.xml
<resources>
<string name="app_name">My App - Paid</string>
</resources>
Icon Resource:
Free path: /free/res/drawable/icon.png
(Imagem Free)
Paid path: /paid/res/drawable/icon.png
(Imagem Paid)
Question
How would it be possible to have a similar configuration to that for a Ionic2/Cordova project, which is possible with the same code base generate 2 applications with a few different features, to be distributed in stores simultaneously and independently?
Well, you may have stumbled into this already, but this guy created this Gulp tasks to modify the config.xml
file on build-time for this purpose.
Also in this forum topic he explains how to obtain the current version for conditional in-app code.
Another related topics are: Configure build flavors for cordova which recommends using Cordova Hooks to modify the config.xml
file based on enviroment variables, as discussed in here: Using environment variables / parameterizing config.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With