Unknown provider: $ionicAppProvider

All we need is an easy explanation of the problem, so here it is.

I get this error when I try to set GCM push’s api key in app.js

Here is the code I use:

.config(['$ionicAppProvider', function($ionicAppProvider) {
    // Identify app
    $ionicAppProvider.identify({
        // The App ID for the server
        app_id: 'MY_APP_ID',
        // The API key all services will use for this app
        api_key: 'MY_API_KEY',
        //The GCM project number
        gcm_id: 'MY_GCM_PROJECT_NUMBER'
    });
  }])

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

It looks like you haven’t installed the ionic-service-core module and setup your app with it. You’ll need to do the following:

1) Install Ionic Service Core.
Run ionic add ionic-service-core on the command line for your project

2) Add this script tag to index.html

<script src="lib/ionic-service-core/ionic-core.js"></script>

3) Add the ionic.service.core module to your app.js like so:

angular.module('starter', ['ionic',
  'ionic.service.core',
  'starter.controllers'])

Method 2

Probably you have injected the ionic core service before your module. Try this:

angular.module('starter', [
  'ionic',
  'ionic.service.core',
  'your.module'
]);

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply