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

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

Closed
4 of 5 tasks
julianlecalvez opened this issue Oct 22, 2020 · 8 comments
Closed
4 of 5 tasks

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

julianlecalvez opened this issue Oct 22, 2020 · 8 comments

Comments

@julianlecalvez
Copy link

Bug report

CHECKLIST

  • I have reproduced the issue using the example projector provided the necessary information to reproduce the issue.
  • I have read the documentation thoroughly and it does not help solve my issue.
  • I have checked that no similar issues (open or closed) already exist.

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 :

  • I use at least the Android 5.0 sdk (API 21) because I use the API 28.
  • I have the google play store installed on my device (the launchReview works and take me to my app)
  • I updated the Play Core library to 1.8.2 in my gradle config, but i already was using the 1.8.0 which matches the requirements.

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

Environment information

  • Cordova CLI version
    • 9.0.0 (cordova-lib@9.0.1)
  • Cordova platform version
    • android 8.1.0
  • Plugins & versions installed in project (including this plugin)
cordova-launch-review 4.0.0 "Launch Review"
cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter"
cordova-plugin-badge 0.8.8 "Badge"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-firebase-analytics 4.3.0 "FirebaseAnalyticsPlugin"
cordova-plugin-local-notification 0.9.0-beta.3 "LocalNotification"
cordova-plugin-market 1.2.0 "Market"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-sqlite-storage 3.3.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version"
cordova-support-android-plugin 1.0.1 "cordova-support-android-plugin"
cordova-support-google-services 1.4.0 "cordova-support-google-services"
ionic-plugin-keyboard 2.2.1 "Keyboard"
  • Dev machine OS and version, e.g.
    • OSX
ProductName:	Mac OS X
ProductVersion:	10.13.6
BuildVersion:	17G11023

Runtime issue

  • Device and OS details
    • Samsung Galaxy S7 Edge - Android 8.0.0
    • Huawei P30 Pro - Android 10

Android build issue:

  • Node JS version
    • v10.16.0
  • Gradle version
    • 4.10.3 buildOutputCleanup vcs-1
  • Target Android SDK version
    • 28
  • Android SDK details
Installed packages:=====================] 100% Computing updates...
  Path                               | Version | Description                    | Location
  -------                            | ------- | -------                        | -------
  build-tools;26.0.2                 | 26.0.2  | Android SDK Build-Tools 26.0.2 | build-tools/26.0.2/
  build-tools;28.0.3                 | 28.0.3  | Android SDK Build-Tools 28.0.3 | build-tools/28.0.3/
  build-tools;29.0.2                 | 29.0.2  | Android SDK Build-Tools 29.0.2 | build-tools/29.0.2/
  emulator                           | 29.0.11 | Android Emulator               | emulator/
  extras;android;m2repository        | 30.0.0  | Android Support Repository     | extras/android/m2repository/
  extras;google;google_play_services | 49      | Google Play services           | extras/google/google_play_services/
  extras;google;m2repository         | 25      | Google Repository              | extras/google/m2repository/
  patcher;v4                         | 1       | SDK Patch Applier v4           | patcher/v4/
  platform-tools                     | 29.0.2  | Android SDK Platform-Tools     | platform-tools/
  platforms;android-25               | 3       | Android SDK Platform 25, rev 3 | platforms/android-25/
  platforms;android-26               | 2       | Android SDK Platform 26        | platforms/android-26/
  platforms;android-27               | 3       | Android SDK Platform 27        | platforms/android-27/
  platforms;android-28               | 6       | Android SDK Platform 28        | platforms/android-28/
  sources;android-25                 | 1       | Sources for Android 25         | sources/android-25/
  sources;android-28                 | 1       | Sources for Android 28         | sources/android-28/
  tools                              | 26.1.1  | Android SDK Tools              | tools/

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
Copy link
Owner

dpa99c commented Oct 22, 2020

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

@julianlecalvez
Copy link
Author

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
Copy link
Owner

dpa99c commented Oct 22, 2020

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.

@dpa99c dpa99c closed this as completed Oct 22, 2020
@julianlecalvez
Copy link
Author

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
Copy link
Author

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
Copy link

rolinger commented Oct 28, 2020

@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
Copy link

@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
Copy link

rolinger commented Oct 28, 2020

@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);
});

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

3 participants