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

New 4.0.0 rating(result) is returning 0, dialog not opening. #26

Closed
3 tasks
rolinger opened this issue Oct 28, 2020 · 5 comments
Closed
3 tasks

New 4.0.0 rating(result) is returning 0, dialog not opening. #26

rolinger opened this issue Oct 28, 2020 · 5 comments

Comments

@rolinger
Copy link

rolinger commented Oct 28, 2020

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.

Current behavior:

This is breaking on v4.0.0 on Android versions 7 - 10, but older version 3.1.1 still works on v7 - 10. I don't have an Android 11 device (yet) to test on so I don't know the behavior for v11.

Result is returning value 0, not opening dialog but also causing external app review to not launch.
LaunchReview.rating(function(result) { // result = 0, unexpected }

Expected behavior:

On Android, using old v3.1.1 advanced code or the new v4.0.0 advanced code, rating result returns value while also not prompting for dialog box or launching external app store review. Condition 0 is not an expected response.

Steps to reproduce:

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

LaunchReview.rating(function(result){
     console.log(result) ;   // value is 0, android does nothing.
     if(cordova.platformId === "ios"){
        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");  // console msg prints, but nothing happens.
    } 
    
},function(err){
    console.log("Error opening rating dialog: " + err);
});

To fix, I had to add:

    } else if(cordova.platformId === "android"){
        console.log("Rating dialog displayed");   // but nothing happens
        if (result === 0) {
           // call extneral launch function
           $scope.rateAppLaunch() ;
        }
    } 
@rolinger rolinger changed the title New 4.0.0 rating(result) is returning 0 New 4.0.0 rating(result) is returning 0, dialog not opening. Oct 28, 2020
@rolinger
Copy link
Author

For android, here is my fix:

    LaunchReview.rating(function(result){
      if (cordova.platformId === "android"){
        if (result === 0) {
          errMgmt("menu/rateApp",2601.3,"Android: In-App Review failed, opening store review.") ;      
          $scope.rateAppStore() ;          
        } else {
          errMgmt("menu/rateApp",2601.4,"Android: In-App Review opened.") ;      
        }
      } else if(cordova.platformId === "ios"){
        if (result === "requested"){
          ratingTimerId = setTimeout(function(){
          $scope.rateAppStore() ;
          }, MAX_DIALOG_WAIT_TIME);
        } else if (result === "shown"){
          errMgmt("menu/rateApp",2601.5,"iOS: In-App Review opened.") ;      
          clearTimeout(ratingTimerId);
        } else if (result === "dismissed"){
        } else {
          // default open app store review
          errMgmt("menu/rateApp",2601.6,"iOS: In-App Review failed, opening store review.") ;      
          
        }
      }
    },function(err){
      errMgmt("menu/rateApp",2601.7,"In-App Review function failed, opening store review.") ;      
      $scope.rateAppStore() ;     
    });
  }

@panderium-art
Copy link

The same thing happened to me on Android. I'm receiving status == 0 and dialog is not opening. I tested on Galaxy Note 10, Android 10.

Packages version:

cordova: 8.1.2,
cordova-android: 7.1.2,
cordova-ios: 5.1.1,
cordova-launch-review: 4.0.0

Code usage:

const LaunchReview: LaunchReviewPlugin = window.LaunchReview;
const platformId = window.cordova && window.cordova.platformId;

const IOS: string = 'ios';
const ANDROID: string = 'android';
const MAX_DIALOG_WAIT_TIME: number = 5000;
let ratingTimerId: NodeJS.Timeout;

export const cordovaDriver = {
    rating: () => new Promise((resolve, reject) => {
        LaunchReview.rating((status => {
            if (platformId === ANDROID) {
                const message = 'Rating dialog displayed';
                resolve({status: PROMPT_DISPLAY_STATUS.SHOWN, message})
            }else if (platformId === IOS) {
                if (status === PROMPT_DISPLAY_STATUS.REQUESTED) {
                    ratingTimerId = setTimeout(() => {
                        const message = `Rating prompt was not shown after ${MAX_DIALOG_WAIT_TIME}ms`;
                        reject( message);
                    }, MAX_DIALOG_WAIT_TIME);
                } else if (status === PROMPT_DISPLAY_STATUS.SHOWN) {
                    clearTimeout(ratingTimerId);
                    const message = 'Rating prompt was shown';
                    resolve({status: PROMPT_DISPLAY_STATUS.SHOWN, message})
                }
            }
        }), (err) => {
            const errMessage = `Error opening rating prompt: ${err}`;
            reject(errMessage);
        });
    }),
}

Calling this method by:

export async function showAppRatingPrompt () {
    // Service-level method
    try {
        return await cordovaDriver.rating()
    }catch (err) {
        console.error(`[ LAUNCH REVIEW SERVICE ] ${err}`)
    }
}

@dpa99c
Copy link
Owner

dpa99c commented Oct 29, 2020

Will take a look into this when I get a moment

@Wunderkemmer
Copy link

I'm integrating this module and I'm also seeing the same 0 result for android, as described above in the first example, with the same code.

@dpa99c dpa99c closed this as completed in 8492d0c Oct 30, 2020
@dpa99c
Copy link
Owner

dpa99c commented Oct 30, 2020

Just published a fix for this issue in v4.0.1

See updated documentation and example project for reference.

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

No branches or pull requests

4 participants