问题
I am Building multiple ionic apps, app rate option in other apps perfectly but in one app its not showing app rate prompt even. My app rate function looks like following
rate(){
this.appRate.preferences.storeAppURL = {
// ios: '',
android: 'market://details?id=app_id',
// windows: 'ms-windows-store://review/?ProductId=<store_id>'
};
this.appRate.promptForRating(true);
// or, override the whole preferences object
this.appRate.preferences = {
usesUntilPrompt: 3,
storeAppURL: {
// ios: '<app_id>',
android: 'market://details?id=app_id',
// windows: 'ms-windows-store://review/?ProductId=<store_id>'
}
};
this.appRate.promptForRating(false);
}
and html code is
<button ion-button color="vibrant" (click)="rate()"><span style="color:#e2c767">Rate App Now</span></button>
回答1:
You need to add other configuration settings. I committed the same mistake that you have inadvertently made. Include the following code in the constructor,
appRate.preferences = {
storeAppURL: {
ios: '<app_id>',
android: 'market://details?id=<package_name>',
windows: 'ms-windows-store://review/?ProductId=<store_id>'
},
customLocale: {
title: 'Do You Enjoy?',
message: 'Please Rate Us',
cancelButtonLabel: 'No Thanks',
laterButtonLabel: 'Remind me later',
rateButtonLabel: 'Rate It Now',
},
callbacks: {
onRateDialogShow: function (callback) {
console.log('dfcsd');
},
onButtonClicked:function(buttonIndex){
console.log('Selected Index is '+buttonIndex);
}
},
simpleMode:true
}
Add the full configurations settings including the callbacks and customLocale as evident from the code above. And then finally, in the rate() function,
this.appRate.promptForRating(true);
回答2:
What language is your device set to?
There is currently a bug in the plugin if your device is set to any language other than English or Portuguese. I have opened an issue here and added possible solutions: https://github.com/pushandplay/cordova-plugin-apprate/issues/218
PS: I'm assuming that the code after // or, override the whole preferences object
is commented out when you test it. Because otherwise, you have 2 promptForRating
calls in the same, which doesn't make sense.
来源:https://stackoverflow.com/questions/52148398/ionic-native-app-rate-not-working-for-android