评级插件不适用于 Ionic 3

Rating plugin not working on Ionic 3

我遵循了这个教程:http://ionicframework.com/docs/native/app-rate/

我正在使用第二种方法,但出现此错误:

Uncaught (in promise): TypeError: Cannot read property 'split' of undefined TypeError: Cannot read property 'split' of undefined at Function.Locales.getLocale (http://192.168.1.2:8100/plugins/cordova-plugin-apprate/www/locales.js:53:74) at showDialog (http://192.168.1.2:8100/plugins/cordova-plugin-apprate/www/AppRate.js:91:29) at Function.AppRate.promptForRating (http://192.168.1.2:8100/plugins/cordova-plugin-apprate/www/AppRate.js:203:7) at callCordovaPlugin (http://192.168.1.2:8100/build/vendor.js:77234:43) at http://192.168.1.2:8100/build/vendor.js:77260:28 at http://192.168.1.2:8100/build/vendor.js:58635:17 at new t (http://192.168.1.2:8100/build/polyfills.js:3:20886) at tryNativePromise (http://192.168.1.2:8100/build/vendor.js:58634:20) at getPromise (http://192.168.1.2:8100/build/vendor.js:58642:12) at wrapPromise (http://192.168.1.2:8100/build/vendor.js:77243:78)

如果我删除此行,我不会触发评级,但其他任何事情都不会失败: this.appRate.promptForRating(true);

这是我正在使用的插件: https://github.com/pushandplay/cordova-plugin-apprate

有同样的问题,添加这行后我能够看到弹出对话框;

useLanguage: 'en',

出现另一个错误,使用下面的回调函数很容易修复;

  callbacks: {
    onButtonClicked: function (buttonIndex) {
      console.log("onButtonClicked -> " + buttonIndex);
    }

这工作正常。我得到这个 from here.

import { AppRate } from '@ionic-native/app-rate';
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { HomePage } from '../pages/home/home';
@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage: any = HomePage;

  constructor(platform: Platform, private appRate: AppRate, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
      statusBar.styleDefault();
      splashScreen.hide();

      this.appRate.preferences = {
        openStoreInApp: false,
        displayAppName: 'Simons App',
        usesUntilPrompt: 2,
        promptAgainForEachNewVersion: false,
        storeAppURL: {
          ios: '1216856883',
          android: 'market://details?id=com.devdactic.crossingnumbers'
        },
        customLocale: {
          title: 'Do you enjoy %@?',
          message: 'If you enjoy using %@, would you mind taking a moment to rate it? Thanks so much!',
          cancelButtonLabel: 'No, Thanks',
          laterButtonLabel: 'Remind Me Later',
          rateButtonLabel: 'Rate It Now'
        },
        callbacks: {
          onRateDialogShow: function(callback){
            console.log('rate dialog shown!');
          },
          onButtonClicked: function(buttonIndex){
            console.log('Selected index: -> ' + buttonIndex);
          }
        }
      };

      // Opens the rating immediately no matter what preferences you set
      this.appRate.promptForRating(true);
    });
  }
}