pushandplay / cordova-plugin-apprate

This plugin provide the "rate this app" functionality into your Cordova/Phonegap application
Apache License 2.0
299 stars 192 forks source link

Error hitting rate button in dialog #268

Open diogoandrei opened 4 years ago

diogoandrei commented 4 years ago

Hi, I'm having an issue when the user click to rate in dialog. I'm testing with a <packagename>of an app that already is published in play store. But when I hit the rate button it does nothing and throws the exception below

Running version: "cordova-plugin-apprate": "^1.5.0",

Exception: TypeError: Cannot read property 'open' of undefined at Object.openUrl (file:///android_asset/www/plugins/cordova-plugin-apprate/www/AppRate.js:218:30) at Function.AppRate.navigateToAppStore (file:///android_asset/www/plugins/cordova-plugin-apprate/www/AppRate.js:257:27) at promptForStoreRatingWindowButtonClickHandler (file:///android_asset/www/plugins/cordova-plugin-apprate/www/AppRate.js:85:17) at Object.callbackFromNative (file:///android_asset/www/cordova.js:287:58) at <anonymous>:1:9

My code:

`window.AppRate.init();
        window.AppRate.preferences = {
            usesUntilPrompt: 5,
            promptAgainForEachNewVersion: false,
            inAppReview: true,
            storeAppURL: {
                ios: 'myid',
                android: 'market://details?id=<mypackage>',
            },
            customLocale: {
                title: "Você poderia nos avaliar?",
                message: "Não vai levar mais que 1 minuto e o seu feedback é muito importante. Obrigado!",
                cancelButtonLabel: "Não, obrigado",
                laterButtonLabel: "Lembrar mais tarde",
                rateButtonLabel: "Avaliar agora",
                yesButtonLabel: "Sim!",
                noButtonLabel: "Não",
                appRatePromptTitle: 'E então, tem gostado do app?',
                feedbackPromptTitle: 'Poderia nos dar um feedback?',
            },
            callbacks: {
                handleNegativeFeedback: function () {
                    window.open('mailto:email', '_system');
                },
                onRateDialogShow: function (callback) {
                    callback(1) // cause immediate click on 'Rate Now' button
                },
                onButtonClicked: function (buttonIndex) {
                    console.log("onButtonClicked -> " + buttonIndex);
                }
            },
            openUrl: window.AppRate.preferences.openUrl
        };
        window.AppRate.promptForRating();`
mukeshsolanki commented 4 years ago

any update on this?

SiempreProgramadorNovato commented 4 years ago

openurl parameter is failing, so you have to attach the callback function instead.. this code is working with latest version of cordova.

`AppRate.init(); AppRate.preferences = { displayAppName: 'My GreatApp', usesUntilPrompt: 3, promptAgainForEachNewVersion: false, inAppReview: true, simpleMode: true, storeAppURL: { ios: '', android: 'market://details?id=com.facebook.katana', windows: 'ms-windows-store://pdp/?ProductId=', blackberry: 'appworld://content/[App Id]/', windows8: 'ms-windows-store:Review?name=' }, customLocale: { title: "Rate My App", message: "My custom message", cancelButtonLabel: "No, Thank", laterButtonLabel: "Later", rateButtonLabel: "Rate Now", yesButtonLabel: "Yes!", noButtonLabel: "Not really", appRatePromptTitle: 'Do you like using %@', feedbackPromptTitle: 'Mind giving us some feedback?', }, callbacks: { handleNegativeFeedback: function() { window.open('mailto:feedback@example.com', '_system'); }, onRateDialogShow: function(callback) { callback(1) // cause immediate click on 'Rate Now' button }, onButtonClicked: function(buttonIndex) { console.log("onButtonClicked -> " + buttonIndex); } } };

AppRate.preferences.openUrl = function(url) { window.open(url, '_blank', 'location=yes'); }; AppRate.promptForRating(); //you can put false here to use usesUntilPrompt instead`