2017-07-10 78 views
0

我试图测试我的离子应用程序,但每次我服务它,我得到一个空白屏幕和导航栏。我收到一个错误,看起来像这个花了无数小时看,但没有。科尔多瓦插件Apprate没有定义。

`Uncaught ReferenceError: AppRate is not defined 
    at Object.setPreferences (ng-cordova.min.js:7) 
    at Array.<anonymous> (config.js:24) 
    at onPlatformReady (ionic.bundle.js:2496) 
    at onWindowLoad (ionic.bundle.js:2477)` 

     angular.module("ngCordova.plugins.appRate", []).provider("$cordovaAppRate", [function() { 
     this.setPreferences = function(e) { 
      e && angular.isObject(e) && (AppRate.preferences.useLanguage = e.language || null, 
      AppRate.preferences.displayAppName = e.appName || "", 
      AppRate.preferences.promptAgainForEachNewVersion = e.promptForNewVersion || !0, 
      AppRate.preferences.openStoreInApp = e.openStoreInApp || !1, 
      AppRate.preferences.usesUntilPrompt = e.usesUntilPrompt || 3, 
      AppRate.preferences.useCustomRateDialog = e.useCustomRateDialog || !1, 
      AppRate.preferences.storeAppURL.ios = e.iosURL || null, 
      AppRate.preferences.storeAppURL.android = e.androidURL || null, 
      AppRate.preferences.storeAppURL.blackberry = e.blackberryURL || null, 
      AppRate.preferences.storeAppURL.windows8 = e.windowsURL || null) 
     } 

这是我每次通过离子CLI为我的应用程序提供的错误。我试过更新插件,但没有什么请帮忙。这是我的离子信息:

global packages: 

    @ionic/cli-utils : 1.4.0 
    Cordova CLI  : 7.0.1 
    Gulp CLI   : not installed globally 
    Ionic CLI  : 3.4.0 

local packages: 

    @ionic/cli-plugin-cordova : 1.4.0 
    @ionic/cli-plugin-gulp : 1.0.1 
    @ionic/cli-plugin-ionic1 : 2.0.0 
    Cordova Platforms   : android 5.1.1 ios 4.4.0 
    Ionic Framework   : ionic1 1.3.1 

System: 

    Node  : v7.4.0 
    OS   : macOS Sierra 
    Xcode  : Xcode 8.3.3 Build version 8E3004b 
    ios-deploy : 1.9.1 
    ios-sim : 6.0.0 
    npm  : 4.0.5 
+0

你在浏览器中运行它吗? – robbannn

+0

是的,但我也把它放在测试飞行,并试图在我的手机上测试它,仍然没有出现。但是navbar @robbannn – NazNeutron

回答

0

在cordova onDeviceReady事件触发后,确保所有对插件的调用都发生。 对于Ionic,您应该将代码移动到$ ionicPlatform.ready()回调中。

$ionicPlatform.ready(function() { 
    if(window.cordova){ 
    AppRate.preferences.displayName = "MyApp" 
    AppRate.preferences.storeAppURL = { 
     ios: '<my_app_id>', 
     android: 'market://details?id=my_app_id' 
    }; 
    } 
}); 
相关问题