We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
ReferencesApplication ServicesAppGallery KitArkTS APIscommentManager (App Review Service)

commentManager (App Review Service)

Phone6.0.0(20)+PC/2in16.0.0(20)+Tablet6.0.0(20)+

This module provides the in-app review capability, allowing users to leave feedback without navigating to the app details page on AppGallery

NOTE

Exceptions need to be captured when an API is called.

Since: 6.0.0(20)

Modules to Import

Collapse
Word wrap
Dark theme
Copy code
  1. import { commentManager } from '@kit.AppGalleryKit';

commentManager.showCommentDialog

Phone6.0.0(20)+PC/2in16.0.0(20)+Tablet6.0.0(20)+

showCommentDialog(context: common.UIExtensionContext | common.UIAbilityContext): Promise<void>

Launches an app review pop-up. This API uses a promise to return the result.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.AppGalleryService.Distribution.Comment

Since: 6.0.0(20)

Parameters:

Expand
Parameter Type Mandatory Description
context common.UIExtensionContext | common.UIAbilityContext Yes App context.

Returns:

Expand
Type Description
Promise<void> Promise that returns no value.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

Expand
Error Code Error Message
1021500001 Internal system error.
1021500002 Service request failed.
1021500003 Failed to connect to AppGallery.
1021500004 Failed to write parameters.
1021500005 The app context is invalid.
1021500006 The user has not signed in to their HUAWEI ID.
1021500007 The user has already commented on the current version.
1021500008 The number of comments has reached the maximum limit.
1021500009 The user has already left a comment, and less than a year has elapsed since then.

Example:

Collapse
Word wrap
Dark theme
Copy code
  1. import { commentManager } from '@kit.AppGalleryKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. import type { common } from '@kit.AbilityKit';
  4. import { BusinessError } from '@kit.BasicServicesKit';
  5. @Entry
  6. @Component
  7. struct Index {
  8. @State message: string = 'showCommentDialog'
  9. build() {
  10. Row() {
  11. Column() {
  12. Text(this.message)
  13. .fontSize(50)
  14. .fontWeight(FontWeight.Bold)
  15. .onClick(() => {
  16. try {
  17. const uiContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
  18. // Launch an app review pop-up.
  19. commentManager.showCommentDialog(uiContext).then(()=>{
  20. hilog.info(0, 'TAG', "succeeded in showing commentDialog.");
  21. }).catch((error: BusinessError<Object>) => {
  22. hilog.error(0, 'TAG', `showCommentDialog failed, Code: ${error.code}, message: ${error.message}`);
  23. });
  24. } catch (error) {
  25. hilog.error(0, 'TAG', `showCommentDialog failed, Code: ${error.code}, message: ${error.message}`);
  26. }
  27. })
  28. }
  29. .width('100%')
  30. }
  31. .height('100%')
  32. }
  33. }