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

Rate Dialog is not showing. #70

Closed
MuhammadAliKust opened this issue Aug 28, 2020 · 20 comments
Closed

Rate Dialog is not showing. #70

MuhammadAliKust opened this issue Aug 28, 2020 · 20 comments
Assignees
Labels
bug Something isn't working

Comments

@MuhammadAliKust
Copy link

Hi,
Thanks for this wonderfull package. But I am unable to use it. I am writing following code but

rateMyApp.shouldOpenDialog

is always returning false.

I am writing code in main.dart

My code is:

RateMyApp rateMyApp = RateMyApp(
    preferencesPrefix: 'rateMyApp_',
    minDays: 0,
    minLaunches: 0,
    remindDays: 7,
    remindLaunches: 10,
    googlePlayIdentifier: 'fr.skyost.example',
    appStoreIdentifier: '1491556149',
  );

  @override
  void initState() {
    super.initState();
    _model.getLoggedInStatus().then((value) {
      setState(() {
        userIsLoggedIn = value;
      });
    });

    rateMyApp.init().then((_) {
      if (rateMyApp.shouldOpenDialog) {
        print("Rate App");
        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.
        );

        // Or if you prefer to show a star rating bar :

        rateMyApp.showStarRateDialog(
          context,
          title: 'Rate this app', // The dialog title.
          message:
              'You like this app ? Then take a little bit of your time to leave a rating :', // The dialog message.
          // contentBuilder: (context, defaultContent) => content, // This one allows you to change the default dialog content.
          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);
                },
              ),
            ];
          },
          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.
            titleAlign: TextAlign.center,
            messageAlign: TextAlign.center,
            messagePadding: EdgeInsets.only(bottom: 20),
          ),
          starRatingOptions:
              StarRatingOptions(), // Custom star bar rating options.
          onDismissed: () => rateMyApp.callEvent(RateMyAppEventType
              .laterButtonPressed), // Called when the user dismissed the dialog (either by taping outside or by pressing the "back" button).
        );
      }
    });
  }

Thanks in advance.

@MuhammadAliKust MuhammadAliKust added the bug Something isn't working label Aug 28, 2020
@RafaelR7
Copy link

Hi, I'm having the same problem, rateMyApp.shouldOpenDialog is always returning false.
It's not clear what configurations we need so the shouldOpenDialog become true.

@TetsuFe
Copy link

TetsuFe commented Sep 11, 2020

Android or iOS, or both?

@RafaelR7
Copy link

I tested only on Android

@TetsuFe
Copy link

TetsuFe commented Sep 11, 2020

I'm Sorry I should wrote as below in recent comment
My app also doesn't work on Android, but work on iOS

@RafaelR7
Copy link

Good to know that package is working on iOS, normally is the opposite.

@Skyost
Copy link
Owner

Skyost commented Sep 11, 2020

@RafaelR7 : It's not clear what configurations we need so the shouldOpenDialog become true.

Well you need to meet the values provided to minDays and minLaunches. I think it's pretty much straightforward.

Anyway I can't reproduce the bug you've described. If you have initialized the plugin with different values, then it can be the problem. Let's say I initialize Rate My App today (09/11/2020) like this :

RateMyApp rateMyApp = RateMyApp(
  preferencesPrefix: 'rateMyApp_',
  minDays: 3,
  minLaunches: 5,
  remindDays: 7,
  remindLaunches: 10,
  //googlePlayIdentifier: 'fr.skyost.example',
  //appStoreIdentifier: '1491556149',
);

Then the plugin will save day to open: 09/12/2020 in the config. Then if you initialize it like this :

RateMyApp rateMyApp = RateMyApp(
  preferencesPrefix: 'rateMyApp_',
  minDays: 0,
  minLaunches: 0,
  remindDays: 7,
  remindLaunches: 10,
  //googlePlayIdentifier: 'fr.skyost.example',
  //appStoreIdentifier: '1491556149',
);

The plugin will still read day to open: 09/12/2020 from the config. You'll have to call reset() if you don't want such things to happen. I think it can be your problem @MuhammadAliKust, @RafaelR7, @TetsuFe ?

@Skyost
Copy link
Owner

Skyost commented Sep 11, 2020

I repost your message @yenyichau :

I guess it is because it return true only on the first day.
minDays: 0
minLaunches: 1

After the next day it should return true as well because of remind but it doesn't return true. Later button was pressed on the first day.
remindDays: 1
remindLaunches: 1

Any idea how to solve this issue ?

@RafaelR7
Copy link

@Skyost Sorry, only after I wrote my comment, I saw on the readme the explanation about the shouldOpenDialog

@TetsuFe
Copy link

TetsuFe commented Sep 11, 2020

@Skyost
I didn't reset so maybe my mistake. sorry and thanks!

@RafaelR7
Copy link

@Skyost using reset worked, thanks. Another question, I tried to use the launchStore() when the user taps on rate button, but it's not working, my applicationId is correct, and I'm running on physical device on release mode, Am I missing something?

@Skyost
Copy link
Owner

Skyost commented Sep 11, 2020

@TetsuFe Hope it works for you. Don't hesitate to tell me if anything goes wrong.

@RafaelR7 Do you get the same error as #73 ?

@RafaelR7
Copy link

@Skyost unfortunately, it doesn't throw any error

@Skyost
Copy link
Owner

Skyost commented Sep 11, 2020

@RafaelR7 #73 is not throwing any error, it's just canOpenURL that returns false on some iOS devices. Are you on iOS ? If not, is the launchStore method doing anything (launch the browser for example, ...) ?

@RafaelR7
Copy link

@Skyost I'm testing on Android

@Skyost
Copy link
Owner

Skyost commented Sep 11, 2020

@RafaelR7 I've changed how the plugin handles url launches in the latest commit. Could you please try it and see if it works for you ? You can try it using :

dependencies:
  rate_my_app:
    git:
      url: https://github.com/Skyost/RateMyApp
      ref: master

(in your pubspec.yml)

@RafaelR7
Copy link

RafaelR7 commented Sep 11, 2020

@Skyost I tried, but it didn't work, it just launch a black screen

@FetFrumos
Copy link

I use your plugin for iOS. It is working in debug mode(rate window appears), but not work in release mode. I published my app to TestFlight. any advice?

@yenyichau
Copy link

After I pressed later button on the first day, it will not pop up the dialog again.

Here is how I initialize Rate My App.
RateMyApp rateMyApp = RateMyApp( minDays: 0, minLaunches: 1, remindDays: 1, remindLaunches: 1);

Question 1:
From the initialize above, minDays 0 & minLaunches 1 because I want to show it on the first launch. For my understanding after pressed later button it will go to remindDays & remindLaunches logic right ?

Question 2:
When should I use rateMyApp.reset() ? If we clear cache & data isn't it will reset automatically ?

@Skyost
Copy link
Owner

Skyost commented Sep 15, 2020

@FetFrumos See this comment.

@yenyichau :

Question 1 :
You're right.

Question 2 :
As long as you clear the shared preferences data (NSUserDefaults on iOS and SharedPreferences on Android), it's reset. Anyway, you should call rateMyApp.reset() when you've changed the Rate my app constructor parameters (or just when you want to reset the plugin data).

@MuhammadAliKust
Copy link
Author

Thanks alot for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants