My app, auroras.live, has been out in the app stores for about two months now. There’s two versions available, a free and a paid version. Previously I was maintaining three GitHub branches — Master, Free and Paid. I’d make the changes in master, then make a PR to sync free and paid, then edit the config.xml in the respective repos so the app would detect and use the appropriate version.
After a while, this got tedious because I’d have to ensure all three branches were in sync, except for the config.xml file (which got reformatted each time a plugin was added), so I gave up on the idea. Gulp seemed like a great fit for all of this, so I whipped up a quick gulpfile that does a few things for me:
- Sets the app name (e.g. Auroras.live Free or Auroras.live)
- Sets the app ID (e.g. live.auroras.app.free or live.auroras.app)
- Copies the correct icon file, then runs
ionic resources
to generate the proper icons - Builds the production version of the app
- Signs the JAR, then runs zipalign.
All I need to do is call gulp build-android-free
or gulp build-android-paid
and it’s all done. No more manually editing config files, no more copying files around. It’s easy! Want this for your own app? The code is below:
All you need to do is:
- Run
npm install --save xmldoc
in addition to the other dependencies for Ionic’s default gulpfile - Edit gulpfile.js and replace the defaults at the top of the file with your own.
- Go into your resources folder and make two icons: icon_free.png and icon_paid.png.
- Call either
gulp build-android-free --storepass mykeystorepassword
orgulp build-android-paid --storepass mykeystorepassword
- You can also call this script with a few parameters:
--packageid
– Sets the package ID--packagename
– Sets the package name--jarsigner
– Path to jarsigner--zipalign
– Path to zipalign--keystore
– Path to your keystore file--keystorealias
– The alias of your keystore
Hi,
Tks for your post. How do you test in the app if is a free or paid version?
best regards