AppRate.preferences.openUrl 不是函数
AppRate.preferences.openUrl is not a function
我最近安装了适用于 Ionic Cordova 的 AppRate 插件,当我单击按钮对应用程序进行评分时遇到问题,它在控制台上显示我的错误:AppRate.preferences.openUrl 不是函数
我试图在首选项中找到属性,但我没有找到。
这是我使用的代码:
appRate.preferences = {
displayAppName: "My app name",
promptAgainForEachNewVersion: true,
storeAppURL: {
ios: '*******',
android: 'market://apps/details?id=com.****.****'
},
customLocale: {
title: "Você está gostando do %@?",
message: "Se você está gostando do %@, poderia nos ajudar avaliando-o na loja?",
cancelButtonLabel: "Não, obrigado",
laterButtonLabel: "Me lembre mais tarde",
rateButtonLabel: "Avaliar",
appRatePromptTitle: "Gostaria de avaliar o nosso aplicativo?",
feedbackPromptTitle: "feedback prompt",
noButtonLabel: "Não",
yesButtonLabel: "Sim"
},
usesUntilPrompt: 1,
simpleMode: true,
inAppReview: true,
callbacks: {
onRateDialogShow: function (callback) {
console.log('rate dialog shown!');
},
onButtonClicked: function (buttonIndex) {
console.log('Selected index: -> ' + buttonIndex);
}
},
}
appRate.promptForRating(true);
出于显而易见的原因,我隐藏了 storeAppUrl 值。
这是我的项目的规格:
使用 Ionic 3,Angular-Ionic,AppRate 版本 4.20.0
您忘记使用添加 appRate
到构造函数以及使用 this
关键字:
import { AppRate } from '@ionic-native/app-rate/ngx';
constructor(private appRate: AppRate) { }
this.appRate.preferences = {
displayAppName: "My app name",
promptAgainForEachNewVersion: true,
storeAppURL: {
ios: '*******',
android: 'market://apps/details?id=com.****.****'
},
customLocale: {
title: "Você está gostando do %@?",
message: "Se você está gostando do %@, poderia nos ajudar avaliando-o na loja?",
cancelButtonLabel: "Não, obrigado",
laterButtonLabel: "Me lembre mais tarde",
rateButtonLabel: "Avaliar",
appRatePromptTitle: "Gostaria de avaliar o nosso aplicativo?",
feedbackPromptTitle: "feedback prompt",
noButtonLabel: "Não",
yesButtonLabel: "Sim"
},
usesUntilPrompt: 1,
simpleMode: true,
inAppReview: true,
callbacks: {
onRateDialogShow: function (callback) {
console.log('rate dialog shown!');
},
onButtonClicked: function (buttonIndex) {
console.log('Selected index: -> ' + buttonIndex);
}
},
};
this.appRate.promptForRating(true);
找到解决办法了,貌似插件AppRate的实际版本有这个bug(1.5.0),所以我把它换成1.4.0版本了。
这是许多用户的常见问题,我们可以在他们的 github 存储库中的这些线程中看到:
https://github.com/pushandplay/cordova-plugin-apprate/issues/263
https://github.com/pushandplay/cordova-plugin-apprate/issues/274
试试这个,在 ionic 5 中对我来说效果很好
const appRate: any = window['AppRate'];
const preferences = appRate.getPreferences();
preferences.simpleMode = true;
preferences.storeAppURL = {
ios: "******",
android: "market://details?id=****.****.******"
};
preferences.openUrl = () => {
window.open(preferences.storeAppURL.android,'_blank','location=yes');
};
appRate.setPreferences(preferences);
appRate.promptForRating(true);
我最近安装了适用于 Ionic Cordova 的 AppRate 插件,当我单击按钮对应用程序进行评分时遇到问题,它在控制台上显示我的错误:AppRate.preferences.openUrl 不是函数
我试图在首选项中找到属性,但我没有找到。
这是我使用的代码:
appRate.preferences = {
displayAppName: "My app name",
promptAgainForEachNewVersion: true,
storeAppURL: {
ios: '*******',
android: 'market://apps/details?id=com.****.****'
},
customLocale: {
title: "Você está gostando do %@?",
message: "Se você está gostando do %@, poderia nos ajudar avaliando-o na loja?",
cancelButtonLabel: "Não, obrigado",
laterButtonLabel: "Me lembre mais tarde",
rateButtonLabel: "Avaliar",
appRatePromptTitle: "Gostaria de avaliar o nosso aplicativo?",
feedbackPromptTitle: "feedback prompt",
noButtonLabel: "Não",
yesButtonLabel: "Sim"
},
usesUntilPrompt: 1,
simpleMode: true,
inAppReview: true,
callbacks: {
onRateDialogShow: function (callback) {
console.log('rate dialog shown!');
},
onButtonClicked: function (buttonIndex) {
console.log('Selected index: -> ' + buttonIndex);
}
},
}
appRate.promptForRating(true);
出于显而易见的原因,我隐藏了 storeAppUrl 值。
这是我的项目的规格:
使用 Ionic 3,Angular-Ionic,AppRate 版本 4.20.0
您忘记使用添加 appRate
到构造函数以及使用 this
关键字:
import { AppRate } from '@ionic-native/app-rate/ngx';
constructor(private appRate: AppRate) { }
this.appRate.preferences = {
displayAppName: "My app name",
promptAgainForEachNewVersion: true,
storeAppURL: {
ios: '*******',
android: 'market://apps/details?id=com.****.****'
},
customLocale: {
title: "Você está gostando do %@?",
message: "Se você está gostando do %@, poderia nos ajudar avaliando-o na loja?",
cancelButtonLabel: "Não, obrigado",
laterButtonLabel: "Me lembre mais tarde",
rateButtonLabel: "Avaliar",
appRatePromptTitle: "Gostaria de avaliar o nosso aplicativo?",
feedbackPromptTitle: "feedback prompt",
noButtonLabel: "Não",
yesButtonLabel: "Sim"
},
usesUntilPrompt: 1,
simpleMode: true,
inAppReview: true,
callbacks: {
onRateDialogShow: function (callback) {
console.log('rate dialog shown!');
},
onButtonClicked: function (buttonIndex) {
console.log('Selected index: -> ' + buttonIndex);
}
},
};
this.appRate.promptForRating(true);
找到解决办法了,貌似插件AppRate的实际版本有这个bug(1.5.0),所以我把它换成1.4.0版本了。
这是许多用户的常见问题,我们可以在他们的 github 存储库中的这些线程中看到: https://github.com/pushandplay/cordova-plugin-apprate/issues/263 https://github.com/pushandplay/cordova-plugin-apprate/issues/274
试试这个,在 ionic 5 中对我来说效果很好
const appRate: any = window['AppRate'];
const preferences = appRate.getPreferences();
preferences.simpleMode = true;
preferences.storeAppURL = {
ios: "******",
android: "market://details?id=****.****.******"
};
preferences.openUrl = () => {
window.open(preferences.storeAppURL.android,'_blank','location=yes');
};
appRate.setPreferences(preferences);
appRate.promptForRating(true);