Skip to content

Cannot showRateDialog()  #147

@hoangphuc1103

Description

@hoangphuc1103

Describe the bug
I'm running the app on Android Simulator (Pixel_API_31) and having an issue that the Rating Dialog cannot be displayed

I/flutter ( 9402): │  Are all conditions met to show dialog: Yes

I/PlayCore( 9402): UID: [10167]  PID: [9402] ReviewService : requestInAppReview (com.inspireui.fluxstore)
I/PlayCore( 9402): UID: [10167]  PID: [9402] ReviewService : Initiate binding to the service.
D/EGL_emulation( 9402): app_time_stats: avg=347725.22ms min=64.36ms max=695386.12ms count=2
I/PlayCore( 9402): UID: [10167]  PID: [9402] ReviewService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.inappreviewservice.InAppReviewService})
I/PlayCore( 9402): UID: [10167]  PID: [9402] ReviewService : linkToDeath
I/PlayCore( 9402): UID: [10167]  PID: [9402] OnRequestInstallCallback : onGetLaunchReviewFlowInfo
I/PlayCore( 9402): UID: [10167]  PID: [9402] ReviewService : Unbind from service.

SourceCode

mixin RateMyAppMixin<T extends StatefulWidget> on State<T> {
  final _rateMyApp = RateMyApp(
    // rate app on store
    minDays: 0,
    minLaunches: 1,
    remindDays: 0,
    remindLaunches: 0,
    googlePlayIdentifier: 'com.inspireui.fluxstore',
    appStoreIdentifier: '1469772800',
  );

  void showRateMyApp() async {
    await _rateMyApp.init().then((_) {
      if (kDebugMode) {
        printLog(
            'Are all conditions met to show dialog: ${_rateMyApp.shouldOpenDialog ? 'Yes' : 'No'}');
      }
      _rateMyApp.showRateDialog(
        context,
        title: S.of(context).rateTheApp,
        // The dialog title.
        message: S.of(context).rateThisAppDescription,
        // The dialog message.
        rateButton: S.of(context).rate.toUpperCase(),
        // The dialog 'rate' button text.
        noButton: S.of(context).noThanks.toUpperCase(),
        // The dialog 'no' button text.
        laterButton: S.of(context).maybeLater.toUpperCase(),
        // 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:
              break;
            case RateMyAppDialogButton.later:
              break;
            case RateMyAppDialogButton.no:
              break;
          }

          return true; // Return false if you want to cancel the click event.
        },
        // Set to false if you want to show the native Apple app rating dialog on iOS.
        dialogStyle: const DialogStyle(),
        // Custom dialog styles.
        // Called when the user dismissed the dialog (either by taping outside or by pressing the 'back' button).
        // actionsBuilder: (_) => [], // This one allows you to use your own buttons.
      );
    });
  }

  /// Only use after show dashboard
  void showRatingOnOpen() async {
    if (mounted) {
      await _rateMyApp.init();

      if (isMobile && kAppRatingConfig.showOnOpen) {
        if (_rateMyApp.shouldOpenDialog) {
          await Future.delayed(const Duration(seconds: 1));
          showRateMyApp();
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions