Created
June 2, 2014 14:51
-
-
Save tonylukasavage/a87834dd4e1be4640c29 to your computer and use it in GitHub Desktop.
Inject environment variables into Titanium. Makes shared code easier to manage (no more sanitizing keys in repos). Uses Titanium to encrypt the values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// now you can use it in a titanium app | |
useSomeApi(Ti.App.Properties.getString('SOME_API_KEY')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.init = function (logger, config, cli, appc) { | |
cli.addHook('build.pre.compile', function(build, done) { | |
// inject the environment variable straight into the tiapp. By doing this prior to compiling, | |
// it will be encrypted and made available via Ti.App.Properties.getString() | |
cli.tiapp.properties.SOME_API_KEY = { type: 'string', value: process.env.SOME_API_KEY }; | |
done(); | |
}); | |
}; |
Hi Tony ,
I am also trying to create build for QA and Production with differnt Tiapp Configuration , In above example , i can not find the the way to call init , and it's argument. Do we need to call init explicitly or it gets called implictly.
I have added above init function in alloy.jmk file but it never gets called.
Please suggest.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How could you inject a Google Maps API Key into the android manifest part of tiapp.xml ?