【问题标题】:Rating plugin not working on Ionic 3评级插件不适用于 Ionic 3
【发布时间】:2018-04-19 19:19:52
【问题描述】:

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

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

未捕获(承诺):TypeError:无法读取属性“拆分”的 未定义类型错误:无法读取未定义的属性“拆分” 在 Function.Locales.getLocale (http://192.168.1.2:8100/plugins/cordova-plugin-apprate/www/locales.js:53:74) 在 showDialog (http://192.168.1.2:8100/plugins/cordova-plugin-apprate/www/AppRate.js:91:29) 在 Function.AppRate.promptForRating (http://192.168.1.2:8100/plugins/cordova-plugin-apprate/www/AppRate.js:203:7) 在 callCordovaPlugin (http://192.168.1.2:8100/build/vendor.js:77234:43) 在http://192.168.1.2:8100/build/vendor.js:77260:28http://192.168.1.2:8100/build/vendor.js:58635:17 在新 t (http://192.168.1.2:8100/build/polyfills.js:3:20886) 在 tryNativePromise (http://192.168.1.2:8100/build/vendor.js:58634:20) 在 getPromise (http://192.168.1.2:8100/build/vendor.js:58642:12) 在 wrapPromise (http://192.168.1.2:8100/build/vendor.js:77243:78)

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

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

【问题讨论】:

  • 不确定你是否打开了这个,但是github中有一个bug reported
  • 是的,就是我。但是没有人在回购上回答:(
  • 无论如何我都会用答案更新这两个问题

标签: angular typescript ionic3 cordova-plugins ionic-native


【解决方案1】:

这工作正常。我收到了这个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);
    });
  }
}

【讨论】:

【解决方案2】:

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

useLanguage: 'en',

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

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

【讨论】:

    猜你喜欢
    • 2013-03-06
    • 2014-10-30
    • 1970-01-01
    • 1970-01-01
    • 2018-05-12
    • 1970-01-01
    • 2023-03-09
    • 2018-09-29
    • 2017-05-14
    相关资源
    最近更新 更多