how to keep secret info such as API keys out of source control inside ionic app?
Ignore them in your source control software?
You can also store the settings in a database, e.g. here’s an example for Firebase (but you can use LocalStorage or SqlStorage as well):
import { Injectable } from 'angular2/core';
@Injectable()
export class ConfigService {
public apiKeys: any = {};
public options: any = {};
constructor() {
var firebaseUrl = 'https://yourfirebasename.firebaseio.com/';
// ...
new Firebase(firebaseUrl).child('config').once('value').then((data) => {
this.initialize(data.val());
});
// ...
}
private initialize(config) {
if (config) {
for (let name of Object.keys(config)) {
switch (name) {
case 'apiKeys':
// TODO: Implement a special processing for API-keys.
this.apiKeys = config[name];
break;
// TODO: Process/set some other special settings here.
default:
this.options[name] = config[name];
break;
}
}
}
}
}