dpa99c / cordova-launch-review

Cordova/Phonegap plugin for iOS and Android to assist in leaving user reviews/ratings in the App Stores
71 stars 26 forks source link

Unable to have the rating() function working for android #25

Closed julianlecalvez closed 3 years ago

julianlecalvez commented 3 years ago

Bug report

CHECKLIST

Current behavior:

I try to integrate the plugin in my ionic / cordova application. I don't have any problem with iOS, I get the popup with the app icon and the 5 stars to fill. However, i can't get it with 2 android devices. The isSupportedRating() returns true, but when i run this code (the same that is working for iOS), nothing happens, but i get the success log in the console (with the param variable 0). I put the code below.

It seems it's a configuration issue, or an ionic incompatibility, because there's no other bugs reported about that, and there's no reason it doesn't work. The launchReview function works perfectly, this is why I don't think it's a I tried to look at the Android in-app review documentation, and I checked the requirements :

Expected behavior: Showing the android review popup in the app.

Environment information

Runtime issue

Android build issue:

Available Packages:


**Related code:**
console.log('isRatingSupported ?', this.launchReview.isRatingSupported());

this.launchReview.rating().then((param) => {
    console.log('Successfully launched rating ', param);
}, (err) => {
    console.log("Error launching rating: ", err);
});

**Console output:**

16:32:43.790 isRatingSupported ? true 16:32:43.815 Successfully launched rating 0



Great job for the lib, and I hope anyone will be able to help me :) 
dpa99c commented 3 years ago

Please try building and running the example project app which is a known working codebase for reference.

julianlecalvez commented 3 years ago

Hi, thank for this answer. I installed it, I put the id for my existing app on the play store, and I got the same result : the LaunchReview works work but for the Inapp rating, i only get the success alert on both my android devices.

cordova-launch-review-in-app-rating

cordova-launch-review-is-supported-rating

dpa99c commented 3 years ago

If I run the latest version of the plugin in the example project with the package ID of one of my own apps, it works fine:

So if you're sure the app package ID is valid/exists in the Play Store, then the problem must be in your development environment. I suggest debugging in Android Studio and looking at the logcat output for errors.

However I'm closing this as I'm satisfied from testing that this plugin functionality is working correctly - I also have it deployed in live apps and see it being used by real Android users.

julianlecalvez commented 3 years ago

Even if it's an environment issue (which is a guess), it would be better to let it open in case another developer have the same problem and can help, don't you think ?

julianlecalvez commented 3 years ago

Ok, i tried with a fresh installation of cordova (10.0.0), and android studio on another computer, and the example still doesn't work on android.

rolinger commented 3 years ago

@dpa99c - Something def broke. I have two apps. App-1 is still using LaunchReview @3.1.1 and the external App Store window launches just find. In the newer app, App-2, I am using LaunchReview @4.0.0, but it has the same/identical functions as App-1. But on the newer App-2, but its not prompt the dialog box and the external launch is not opening. I am getting same behavior on two different Android devices running, Android 7 and Android 10. I haven't tested on iOS yet.

Specifically, I am seeing:

$scope.rateApp = function() {
   if (LaunchReview.isRatingSupported()) {
      console.log("Supported: true") ;
      $scope.rateAppReview() ;
   } else {
      console.log("Supported: false") ;
      $scope.rateAppLuanch() ;
   }
}

  $scope.rateAppReview = function() {
    var MAX_DIALOG_WAIT_TIME = 5000; //max time to wait for rating dialog to display
    var ratingTimerId;    
    LaunchReview.rating(function(result) {
      console.log("Rating: "+result) ;  // outputs:  "Rating: 0"
      if (result === "requested") {
        ratingTimerId = setTimeout(function() {
          $scope.rateAppStore() ;
        }, MAX_DIALOG_WAIT_TIME);
      } else if (result === "shown") {
        clearTimeout(ratingTimerId);
      } else if(result === "dismissed") {
      }
    },function(err){
        errMgmt("menu/rateApp",2600.1,"Error opening rating dialog: " + err) ;        
        $scope.rateAppStore() ;
    });
  }

Console is outputting:

Supported: true
Rating: 0

Its not opening the dialog box...and with a rating result == 0, its never making into any of the rating result conditions (ie: requested, shown, dismissed). So, the question is, why would isRatingSupported() return true, but then in rating() itself the result is returning displaying 0 (which I interpret as 'false')?

As a temp work around on App-2, I had to add a result condition to pop the App Store review screens:

    LaunchReview.rating(function(result) {
      console.log("Rating: "+result) ;  // outputs:  "Rating: 0"
      if (result === "requested") {
        ratingTimerId = setTimeout(function() {
          $scope.rateAppStore() ;
        }, MAX_DIALOG_WAIT_TIME);
      } else if (result === "shown") {
        clearTimeout(ratingTimerId);
      } else if(result === "dismissed") {
      } else if (result === 0) {
         $scope.rateAppStore() ;
      }
   }) ;
rolinger commented 3 years ago

@dpa99c - is 4.0.0 specifically for Android 11 thus the updated .rating() returning a result==0 response that means something to Android 11 and has no relevance to Android 7 - 10 ? Just a thought.

rolinger commented 3 years ago

@dpa99c - just took a look at the code again. I see the Advanced .rating() has changed from previous version. I updated my code but the problem is still happening because result==0 and regardless of platform === "android" the dialog box is not prompting and there is no condition to use the external app rating window.

To get it to work, still had to modify with the following - but this works on Android 7 - 10, I have not been able to test it on Android 11 and am thinking my code workaround would cause the in-app dialog launch AND the external app store rating to launch.

var MAX_DIALOG_WAIT_TIME = 5000; //max time to wait for rating dialog to display
var ratingTimerId;

LaunchReview.rating(function(result){
     if(cordova.platformId === "ios" || result === 0){
        if(result === "requested"){
            console.log("Requested display of rating dialog");

            ratingTimerId = setTimeout(function(){
                console.warn("Rating dialog was not shown (after " + MAX_DIALOG_WAIT_TIME + "ms)");
            }, MAX_DIALOG_WAIT_TIME);
        }else if(result === "shown"){
            console.log("Rating dialog displayed");

            clearTimeout(ratingTimerId);
        }else if(result === "dismissed"){
            console.log("Rating dialog dismissed");
        }
    } else if(cordova.platformId === "android"){
        console.log("Rating dialog displayed");
    }

},function(err){
    console.log("Error opening rating dialog: " + err);
});