Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening file:///android_asset/www/null #307

Open
bzimbelman opened this issue Apr 29, 2021 · 0 comments
Open

Opening file:///android_asset/www/null #307

bzimbelman opened this issue Apr 29, 2021 · 0 comments

Comments

@bzimbelman
Copy link

I have the following react/cordova app:

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:
Screen Shot 2021-04-29 at 4 31 42 PM
However, when I select the 'Rate It Now...' button I get:
Screen Shot 2021-04-29 at 4 31 59 PM

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant