user9
user9

Reputation: 145

apprate with XDK does not work

I am using org.pushandplay.cordova.apprate with XDK for Android. It just does not work. Maybe it's a syntax problem, but I cannot figure it out. I have already searched quite some forums with not sufficient answer.

Here's how I did it:

I installed the org.pushandplay.cordova.apprate plugin, newest version.

I put the following code in the file js/app.js:

function rateButton() {
  var customLocale = {};
  customLocale.title = "Rate this App";
  customLocale.message = "Rate this App 5 star if you found it useful!";
  customLocale.cancelButtonLabel = "No, Thanks";
  customLocale.laterButtonLabel = "Remind Me Later";
  customLocale.rateButtonLabel = "Rate It Now";
  AppRate.preferences.openStoreInApp = true;
  AppRate.preferences.storeAppURL.android = 'market://details?id=com.my.project';
  AppRate.preferences.customLocale = customLocale;
  AppRate.preferences.displayAppName = 'My Project';
  AppRate.preferences.usesUntilPrompt = 1;
  AppRate.preferences.promptAgainForEachNewVersion = false;
  AppRate.promptForRating(true);
};

In the html file I put the following:

<button onclick="rateButton()" class="btn btn-primary" type="submit">Rate the app</button>

When I click on the button (within the built app) nothing happens. Do I have to indicate where to find the function? I must admit that I am not quite familiar with Javascript Syntax, but I studied some guides and I couldn't find my mistake.

Upvotes: 3

Views: 114

Answers (2)

user9
user9

Reputation: 145

Thanks a lot to krisrak. It works!

Actually the only thing that was missing was the line referring to cordova.js.

What I did not know is that the cordova.js is automatically produced when putting that code. I am very impressed about XDK. If they only invested some more hours in documentation...

Upvotes: 1

krisrak
krisrak

Reputation: 12952

Seem to work fine, here is the full code I tested:

<!DOCTYPE html>
<html>

  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">  

      <script src="cordova.js"></script>
      <script>

function rateButton() {
  var customLocale = {};
  customLocale.title = "Rate this App";
  customLocale.message = "Rate this App 5 star if you found it useful!";
  customLocale.cancelButtonLabel = "No, Thanks";
  customLocale.laterButtonLabel = "Remind Me Later";
  customLocale.rateButtonLabel = "Rate It Now";
  AppRate.preferences.openStoreInApp = true;
  AppRate.preferences.storeAppURL.android = 'market://details?id=com.my.project';
  AppRate.preferences.customLocale = customLocale;
  AppRate.preferences.displayAppName = 'My Project';
  AppRate.preferences.usesUntilPrompt = 1;
  AppRate.preferences.promptAgainForEachNewVersion = false;
  AppRate.promptForRating(true);
};

      </script>      
  </head>

  <body>
      <br><br>
      <button onclick="rateButton()">Rate</button>

  </body>

</html>

built and worked on android and ios device, u have to change AppRate.preferences.storeAppURL.android value

Upvotes: 0

Related Questions