2015-12-02 86 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印象非常深刻。如果他們只在文件上投入更多時間...