2015-12-02 56 views
3

我正在使用org.pushandplay.cordova.apprate与XDK for Android。它只是不起作用。也许这是一个语法问题,但我无法弄清楚。我已经搜索了很多没有足够答案的论坛。处理XDK不起作用

我是这样做的:

我安装了org.pushandplay.cordova.apprate插件,最新版本。

我把文件的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); 
 
};

在HTML文件中,我把下列:

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

当我点击按钮(在构建的应用程序内)时,没有任何反应。我是否必须指明在哪里可以找到该功能? 我必须承认,我对JavaScript语法不太熟悉,但我学习了一些指南,并且找不到我的错误。

回答

0

似乎做工精细,这里是我测试的全码:

<!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> 

建成并在Android和iOS设备的工作,我只好改变AppRate.preferences.storeAppURL.android

1

由于很多krisrak。有用!

其实唯一缺少的是提到cordova.js的那一行。

我不知道的是cordova.js是在编码时自动生成的。我对XDK印象非常深刻。如果他们只在文件上投入更多时间...