2
votes

I followed this tutorial: http://ionicframework.com/docs/native/app-rate/

I'm using the second approach but I get this error:

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)

If I remove this line I don't trigger the rating but nothing else fails: this.appRate.promptForRating(true);

This is the plugin that I'm using: https://github.com/pushandplay/cordova-plugin-apprate

2
not sure if you opened this, but there is a bug reported in githubSuraj Rao
Yes, that's me. But no one answer on the repo :(Dani
I'll update both questions with the answer anywayDani

2 Answers

0
votes

This is working fine. I got this 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
votes

Had the same issue and I was able to see the popup dialog after adding this line;

useLanguage: 'en',

Another error appeared which was easy to fix using the callback function below;

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