未知提供者:$ ionicAppProvider

mat*_*dev 8 angularjs google-cloud-messaging ionic-framework

当我尝试在app.js中设置GCM push的api键时出现此错误

这是我使用的代码:

.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'
    });
  }])
Run Code Online (Sandbox Code Playgroud)

jca*_*uso 7

看起来您没有安装ionic-service-core模块并使用它设置您的应用程序.您需要执行以下操作:

1)安装Ionic Service Core.ionic add ionic-service-core在项目的命令行上运行

2)将此脚本标记添加到index.html

<script src="lib/ionic-service-core/ionic-core.js"></script>
Run Code Online (Sandbox Code Playgroud)

3)将ionic.service.core模块添加到app.js,如下所示:

angular.module('starter', ['ionic',
  'ionic.service.core',
  'starter.controllers'])
Run Code Online (Sandbox Code Playgroud)

  • 我有这一切,但错误仍然存​​在. (2认同)