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

Beginner question regarding rate_my_app plugin #67

Closed
farazk86 opened this issue Aug 17, 2020 · 11 comments
Closed

Beginner question regarding rate_my_app plugin #67

farazk86 opened this issue Aug 17, 2020 · 11 comments
Assignees
Labels
question Further information is requested

Comments

@farazk86
Copy link
Contributor

Hi,

I apologise in advance for the very beginner question but I am new to flutter and am having trouble trying to implement this plugin.

The example code shown in the plugin is a bit complicated for me as it relies on an additional content.dart file which I tried to make sense of but failed.

This implementation of rate_my_app makes sense to me and is very easy: https://github.com/MarcusNg/flutter_rating_prompt/blob/master/lib/main.dart but it looks like this is for an old version and it does not work with the latest version of the plugin.

From the linked page above this is the part that is outdated:

_rateMyApp.init().then((_) {
      // TODO: Comment out this if statement to test rating dialog (Remember to uncomment)
      // if (_rateMyApp.shouldOpenDialog) {
      _rateMyApp.showStarRateDialog(
        context,
        title: 'Enjoying Flutter Rating Prompt?',
        message: 'Please leave a rating!',
        onRatingChanged: (stars) {
          return [
            FlatButton(
              child: Text('Ok'),
              onPressed: () {
                if (stars != null) {
                  _rateMyApp.doNotOpenAgain = true;
                  _rateMyApp.save().then((v) => Navigator.pop(context));

                  if (stars <= 3) {
                    print('Navigate to Contact Us Screen');
                    // Navigator.push(
                    //   context,
                    //   MaterialPageRoute(
                    //     builder: (_) => ContactUsScreen(),
                    //   ),
                    // );
                  } else if (stars <= 5) {
                    print('Leave a Review Dialog');
                    // showDialog(...);
                  }
                } else {
                  Navigator.pop(context);
                }
              },
            ),
          ];
        },
        dialogStyle: DialogStyle(
          titleAlign: TextAlign.center,
          messageAlign: TextAlign.center,
          messagePadding: EdgeInsets.only(bottom: 20.0),
        ),
        starRatingOptions: StarRatingOptions(),
      );
      // }
    });

The onRatingChanged parameter no longer exists, and I dont know how to replace it.

I am simply wanting to use the plugin to show a popup, after say 5 app launches, if they want to leave a rating.. if yes, they should be directed to the play store link.

That is all, I do not want to measure stars or do anything else.

Can you please help me out here.

Thank you

@Skyost Skyost self-assigned this Aug 18, 2020
@Skyost Skyost added the question Further information is requested label Aug 18, 2020
@Skyost
Copy link
Owner

Skyost commented Aug 18, 2020

Hey,

onRatingChanged has been renamed to actionsBuilder 😉

@farazk86
Copy link
Contributor Author

Hi Skyost, thanks for the reply.

When I replace onRatingChanged to actionsBuilder I get the error:

The argument type 'List<Widget> Function(BuildContext)' can't be assigned to the parameter type 'List<Widget> Function(BuildContext, double)'.

Is there a minimal example I can follow that performs what I want to achieve?

Thank you

@Skyost
Copy link
Owner

Skyost commented Aug 18, 2020

You can use the Example located in the README. It has not only be renamed, but has also been a bit changed :

actionsBuilder: (context, stars) { // Triggered when the user updates the star rating.
  return [ // Return a list of actions (that will be shown at the bottom of the dialog).
    FlatButton(
      child: Text('OK'),
      onPressed: () async {
        print('Thanks for the ' + (stars == null ? '0' : stars.round().toString()) + ' star(s) !');
        // You can handle the result as you want (for instance if the user puts 1 star then open your contact page, if he puts more then open the store page, etc...).
        // This allows to mimic the behavior of the default "Rate" button. See "Advanced > Broadcasting events" for more information :
        await rateMyApp.callEvent(RateMyAppEventType.rateButtonPressed);
        Navigator.pop<RateMyAppDialogButton>(context, RateMyAppDialogButton.rate);
      },
    ),
  ];
},

@farazk86
Copy link
Contributor Author

Thank you, thats much helpful.

I think my issue was following an outdated tutorial and running into problems. In the readme ignoreNative is also changed to ignoreNativeDialog.

I'm not looking at implementing the stars system, I just want a message to ask for rating message so I wrote this in my init()

rateMyApp.init().then((_) {
//      if (rateMyApp.shouldOpenDialog) {
        rateMyApp.showRateDialog(
          context,
          title: 'Rate this app', // The dialog title.
          message: 'If you like this app, please take a little bit of your time to review it !\nIt really helps us and it shouldn\'t take you more than one minute.', // The dialog message.
          rateButton: 'RATE', // The dialog "rate" button text.
          noButton: 'NO THANKS', // The dialog "no" button text.
          laterButton: 'MAYBE LATER', // The dialog "later" button text.
          listener: (button) { // The button click listener (useful if you want to cancel the click event).
            switch(button) {
              case RateMyAppDialogButton.rate:
                print('Clicked on "Rate".');
                break;
              case RateMyAppDialogButton.later:
                print('Clicked on "Later".');
                break;
              case RateMyAppDialogButton.no:
                print('Clicked on "No".');
                break;
            }

            return true; // Return false if you want to cancel the click event.
          },
          ignoreNativeDialog: false, // Set to false if you want to show the Apple's native app rating dialog on iOS or Google's native app rating dialog (depends on the current Platform).
          dialogStyle: DialogStyle(), // Custom dialog styles.
          onDismissed: () => rateMyApp.callEvent(RateMyAppEventType.laterButtonPressed), // Called when the user dismissed the dialog (either by taping outside or by pressing the "back" button).
          // contentBuilder: (context, defaultContent) => content, // This one allows you to change the default dialog content.
          // actionsBuilder: (context) => [], // This one allows you to use your own buttons.
        );
//      }
    });

But the rating dialogue does not show, I get these messages in the console though:

I/PlayCore( 4624): UID: [10153]  PID: [4624] ReviewService : requestInAppReview (com.lewanay.easy_kort)
I/PlayCore( 4624): UID: [10153]  PID: [4624] ReviewService : Initiate binding to the service.
I/PlayCore( 4624): UID: [10153]  PID: [4624] ReviewService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.inappreviewservice.InAppReviewService})
I/PlayCore( 4624): UID: [10153]  PID: [4624] ReviewService : linkToDeath

Thanks

@Skyost
Copy link
Owner

Skyost commented Aug 18, 2020

I think my issue was following an outdated tutorial and running into problems. In the readme ignoreNative is also changed to ignoreNativeDialog.

That's possible ah ah, thank you.

But the rating dialogue does not show

See #64.

@farazk86
Copy link
Contributor Author

I think my issue was following an outdated tutorial and running into problems. In the readme ignoreNative is also changed to ignoreNativeDialog.

That's possible ah ah, thank you.

But the rating dialogue does not show

See #64.

I read that, thank you. But I'm not looking to display the new in-app rating dialogue, I want to display the plugin dialogue.

Thanks

@Skyost
Copy link
Owner

Skyost commented Aug 18, 2020

I read that, thank you. But I'm not looking to display the new in-app rating dialogue, I want to display the plugin dialogue.

Then set ignoreNativeDialog to true.

@farazk86
Copy link
Contributor Author

I read that, thank you. But I'm not looking to display the new in-app rating dialogue, I want to display the plugin dialogue.

Then set ignoreNativeDialog to true.

Oh my youre, right.. its right there, I just didint see it.

Thank you for being patient with me :)

Now, I read this in one of the other closed issues as well, but my understanding is that we will have to implement our own method of opening the play store link after Rate is clicked.. or use something like https://pub.dev/packages/launch_review ?

Thanks

@Skyost
Copy link
Owner

Skyost commented Aug 18, 2020

Now, I read this in one of the other closed issues as well, but my understanding is that we will have to implement our own method of opening the play store link after Rate is clicked..

Using showStarRateDialog, yes. You could use a package like url_launcher or launch_review yes, but Rate my app gives you at least three alternative methods :

  • Omit the actionsBuilder parameter (this will give you the default buttons : Rate, Later and Cancel with their default behavior).
  • Replace the FlatButton I gave you here by a RateMyAppRateButton widget which will open the system app store.
  • Call rateMyApp.launchStore() to launch the system app store.

@farazk86
Copy link
Contributor Author

Thank you so much for your help, its now working as expected.

May I suggest adding this minimal setup example to the readme for the beginners like me amongst us :)

@Skyost
Copy link
Owner

Skyost commented Aug 18, 2020

Don't hesitate to submit me your changes by submitting pull requests ! 😉

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

No branches or pull requests

2 participants