目录

App Review Service

With this service, users can submit reviews directly within the app, without navigating to the details page on AppGallery.

From version 6.0.0(20), the app review pop-up is supported.

Use Cases

You can use this API to launch an app review pop-up, allowing users to rate and comment on your app without navigating to the details page on AppGallery.

Service Process

  1. The user wants to leave a review within the app.

  2. The app calls the showCommentDialog API to launch an app review pop-up.

  3. AppGallery Kit returns the API call result to the app.

  4. The app displays the review pop-up to the user.

Constraints

The app review service does not support the Emulator. Use a real device for debugging.

API Description

The app review service provides the following APIs. For details, please refer to the API reference.

API Description
showCommentDialog(context: common.UIExtensionContext | common.UIAbilityContext): Promise<void> Launches an app review pop-up for users to rate and comment on your app.

Development Procedure

  1. Import the commentManager module and related common modules.

    import { BusinessError } from '@kit.BasicServicesKit';
    import { hilog } from '@kit.PerformanceAnalysisKit';
    import type { common, Want } from '@kit.AbilityKit';
    import { commentManager} from '@kit.AppGalleryKit';
  2. Call showCommentDialog to launch a review pop-up.

    try {
      const uiContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
      commentManager.showCommentDialog(uiContext).then(()=>{
        hilog.info(0, 'TAG', 'succeeded in showing commentDialog.');
      }).catch((error: BusinessError<Object>) => {
        hilog.error(0, 'TAG', `showCommentDialog failed, Code: ${error.code}, message: ${error.message}`);
      });
    } catch (error) {
      hilog.error(0, 'TAG', `showCommentDialog failed, Code: ${error.code}, message: ${error.message}`);
    }

Launching the App Review Page Through an App Linking URL

To open the AppGallery review page for an app, you can use an App Linking URL. In this way, when the relevant API is called by an app or when users tap the link on a web page, the app review page will be launched on the details page, where users can rate and comment on the app.

Construct an App Linking URL by concatenating bundleName and action. bundleName represents the package name of the app for which the review page needs to be launched, while action should be implicitly set to write-review, which indicates that the review page will be launched after the details page is displayed. The format is as follows:

let link: string = 'https://xxx/app/detail?id=' + bundleName + '&action=write-review';

Call the openLink API in an app to launch the page specified by the App Linking URL.

import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import type { common, Want } from '@kit.AbilityKit';
// ...

@Entry
@Component
struct Index {
  // ...

  build() {
    // ...
        Button('start app linking', { type: ButtonType.Capsule, stateEffect: true })
          .width('87%')
          .height('5%')
          .margin({ bottom: '12vp' })
          .onClick(() => {
            let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
            // Configure different app package names to launch review pages of different apps. For example, set bundleName to com.huawei.hmsapp.books.
            let bundleName: string = 'xxxx';
            let link: string = 'https://xxx/app/detail?id=' + bundleName + '&action=write-review';
            // Display the app review page of the specified package name on AppGallery using App Linking as the preferred mode.
            context.openLink(link, { appLinkingOnly: false })
              .then(() => {
                hilog.info(0x0001, 'TAG', 'openlink success.');
              })
              .catch((error: BusinessError) => {
                hilog.error(0x0001, 'TAG', `openlink failed. Code: ${error.code}, message is ${error.message}`);
              });
          })
        // ...
  }
}

Open an App Linking URL on a web page.

<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Redirection example</title>
  </head>
  <body>
    <a href='https://appgallery.huawei.com/app/detail?id=bundleName&action=write-review'>Launch review page on AppGallery through an App Linking URL</a>
  </body>
</html>