import "./App.css";
import React, { useState } from "react";
import AppRate from "cordova-plugin-apprate";
function App() {
console.log(`App starting...`);
const handleClick = () => {
console.log(`handleClick`);
const ref = window.open("http://www.google.com", "_self");
console.log(`opened window`);
};
const rateClick = () => {
console.log(`rateClick`);
AppRate.setPreferences({
storeAppUrl: {
ios: "blah.blah.blah",
android: "market://details?id=blah.blah.blah",
},
reviewType: {
ios: "AppStoreReview",
android: "inAppBrowser",
},
simpleMode: true,
showPromptForInAppReview: false,
customLocale: {
title: "My Title",
message: "My Message",
rateButtonLabel: "Rate It Now...",
cancelButtonLabel: "No, Thanks...",
laterButtonLabel: "Remind Me Later...",
},
callbacks: {
onButtonClicked: function (buttonIndex) {
console.log(`Button Clicked ${buttonIndex}`);
switch (buttonIndex) {
case 1:
console.log(`B1`);
break;
case 2:
console.log(`B2`);
break;
case 3:
console.log(`B3`);
break;
}
},
},
openUrl: function (url) {
console.log(`openUrl to ${url}`);
let safariAvailable = false;
if (window.SafariViewController) {
window.SafariViewController.isAvailable(function (available) {
safariAvailable = available;
});
}
if (!safariAvailable) {
console.log(`no safari, must be a droid...`);
window.open(url, "_blank", "location=yes");
} else {
window.SafariViewController.show(
{
url: url,
barColor: "#0000ff", // on iOS 10+ you can change the background color as well
controlTintColor: "#00ffff", // on iOS 10+ you can override the default tintColor
tintColor: "#00ffff", // should be set to same value as controlTintColor and will be a fallback on older ios
},
// this success handler will be invoked for the lifecycle events 'opened', 'loaded' and 'closed'
function (result) {},
function (msg) {}
);
}
},
});
AppRate.promptForRating();
};
return (
<div className="App">
<header className="App-header">
<p>Hello from React App</p>
<button onClick={handleClick}>Open Google</button>
<button onClick={rateClick}>Rate Me</button>
</header>
</div>
);
}
export default App;
When the Rate Me button is clicked, the expected behavior occurs, i.e. the following options are displayed:
However, when I select the 'Rate It Now...' button I get:
Which is not the expected behavior. From everything I have read about this, I should see the in-app rating.
Also the log messages do show that openUrl is called with null as the argument and that button 3 was clicked. I assume button 3 is the rate button but that the null value for the url is incorrect.
I did try changing the reviewType.android value from "InAppBrowser" to "InAppReview" but the behavior was the same. I have the following plugins installed:
cordova-plugin-apprate
cordova-plugin-dialogs
cordova-plugin-inappbrowser
cordova-plugin-nativestorage
cordova-plugin-whitelist
I have the following react/cordova app:
When the Rate Me button is clicked, the expected behavior occurs, i.e. the following options are displayed:
However, when I select the 'Rate It Now...' button I get:
Which is not the expected behavior. From everything I have read about this, I should see the in-app rating.
Also the log messages do show that openUrl is called with null as the argument and that button 3 was clicked. I assume button 3 is the rate button but that the null value for the url is incorrect.
I did try changing the reviewType.android value from "InAppBrowser" to "InAppReview" but the behavior was the same. I have the following plugins installed: cordova-plugin-apprate cordova-plugin-dialogs cordova-plugin-inappbrowser cordova-plugin-nativestorage cordova-plugin-whitelist