dpa99c / phonegap-launch-navigator

Phonegap/Cordova plugin which launches native route navigation apps for Android, iOS and Windows
369 stars 129 forks source link

[FEATURE] Load GOOGLE_API_KEY_FOR_ANDROID from .env-File #247

Closed carstenbaumhoegger closed 3 years ago

carstenbaumhoegger commented 3 years ago

Feature request

I've just discovered this library and it really helps me with a problem I need to solve.

The only thing I'd love to have is a possibility to let the lib load the GOOGLE_API_KEY_FOR_ANDROID from an .env-file. I think it's problematic to check in API-Keys directly into the repository and it would be great if the plugin could be inited with the key, provided from an .env-file.

If you think this change makes sense for the plugin, I'd be happy to help working on a solution!

dpa99c commented 3 years ago

AFAIK Cordova doesn't support definition of plugin variables via an external file in which case this would require custom hook scripts to hook into the Cordova build lifecycle to inject the API into the appropriate place(s) while maintaining the existing plugin variable functionality. However, if I'm wrong about this assumption or you have an example of another Cordova plugin which provides such behaviour, please let know.

dpa99c commented 3 years ago

This has been addressed by the merge of PR #250 which allows the API key to be set at runtime.

If you still wish to externalise your API key into an untracked file, you can write a custom Cordova hook script which will insert it into the config.xml or app code prior to the Cordova build lifecycle.