-
Notifications
You must be signed in to change notification settings - Fork 25
Firebase configuration
To configure a backend provider e.g. Firebase, edit the appropriate values in the config-base.json
file (under src/js/config
). The config-base.json
file looks like this:
{
"name": "app.config",
"constants": {
"APP": {
"routerDefaultState": "app.auth.main.dash"
},
"FirebaseConfiguration": {
"url": "https://your-firebase-app.firebaseio.com",
"debug": false
},
"TwitterReauthentication": {
"useReauthenticationHack": "false",
"consumerKey": "TWITTER_CONSUMER_KEY",
"consumerSecretKey": "TWITTER_CONSUMER_SECRET"
}
}
}
Here you can configure stuff like:
- the 'default' start page (
routerDefaultState
): this value will be picked up by thegetStartPage
method insideapplication.service.js
- FirebaseConfiguration
- TwitterReauthentication (see below)
NOTE: do NOT change the value of the "name" property ("name": "app.config"), this value is used by the build process (gulp) and should be left unmodified.
The values in the 'FirebaseConfiguration' section are simply placeholders ("FirebaseConfiguration": {"url": "https://your-firebase-app.firebaseio.com"
}).
To set up Firebase: replace "https://your-firebase-app.firebaseio.com"
with your real Firebase URL.
Firebase also has a "debug" option. Be aware that setting this debug
option to true
will generate A LOT of logging. You should only switch it on to debug/troubleshoot Firebase issues which you can't solve otherwise.
To make your app use the Firebase implementation of the service (UserService), follow the guidelines from: https://github.com/leob/ionic-quickstarter/wiki/Dev-mode-and-production-mode-configuration
For an explanation of the 'TwitterReauthentication' config section, see:
In order for the quickstarter app to work properly with Firebase, configure your Firebase instance as described below.
The quickstarter app will store user data under the node "users" in your Firebase database. To secure this, it is highly recommended to create Security Rules for your Firebase instance.
To do this, go into the Firebase dashboard, open your Firebase instance (Firebase URL), click on the "Security and Rules" option at the left side, paste the following JSON snippet into the 'FIREBASE RULES' editor, and click on "Save Rules":
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"users": {
"$uid": {
".write": "auth != null && auth.uid == $uid"
}
}
}
}
Firebase supports multiple authentication providers, e.g. "Email and Password", "Twitter", "Facebook" and so on. The quickstarter app supports two of these ("Email and Password" and "Twitter"). In order to use them you must enable them for your Firebase instance.
To do this, go into the Firebase dashboard, open your Firebase instance (Firebase URL), click on the "Login and Auth" option at the left side, click on the "Email and Password" tab, and select the checkbox "Enable Email & Password Authentication".
If you want to use Twitter authentication then click on the "Twitter" tab of the Firebase "Login and Auth" page, select the checkbox "Enable Twitter Authentication", and enter your Twitter API Key and your Twitter API Secret. For details on how to do this, see: https://github.com/leob/ionic-quickstarter/wiki/Setting-up-Twitter-authentication-with-Firebase.