找回密码
 立即注册
首页 业界区 业界 如何让你的应用在市场中脱颖而出?

如何让你的应用在市场中脱颖而出?

痕伯 2025-6-1 23:18:18
开发者在完成应用开发并成功上架应用市场后,将面临一项重要挑战:如何在竞争激烈的环境中脱颖而出,吸引用户的关注?为此,提升应用的曝光度和下载量至关重要。
HarmonyOS SDK应用市场服务(Store Kit)提供应用市场业务的对外开放能力,针对想要获得曝光的应用,Store Kit提供了应用市场推荐和应用市场更新功能的能力,可以更好地支持应用的下载、推荐和分发等场景,以提高在应用市场上的曝光度,助力开发者商业变现。
应用市场推荐:用户可直达您的应用市场详情页或卡片加桌页面,有效提高您的应用曝光率。
应用市场更新功能:您可以通过本服务,查询应用是否有可更新的版本。当存在可更新版本时,可为用户显示更新提醒。
应用市场推荐场景介绍

元服务卡片加桌

您可调用应用市场服务提供的元服务加桌loadService接口,加载元服务卡片加桌页面,用户点击"添加至桌面"按钮,将元服务卡片添加至桌面。
1.png

应用详情页展示

a.您可调用应用市场服务提供的loadProduct接口,直接加载应用市场的应用详情页面,用户可以在页面内点击"安装"按钮完成应用的下载安装。
b.您可使用DeepLink链接的方式拉起应用市场应用详情页,通过拼接应用市场DeepLink链接,在应用中调用或网页中点击DeepLink链接拉起应用详情页,用户可以在页面内点击"安装"按钮完成应用的下载安装。
c.您可使用App Linking链接的方式拉起应用市场应用详情页,通过拼接应用市场App Linking链接,在应用中调用或网页中点击App Linking链接拉起应用详情页,用户可以在页面内点击"安装"按钮完成应用的下载安装。
2.png

应用市场推荐场景介绍

当应用启动完成或用户在应用中主动检查应用新版本时,开发者可以通过本服务,来查询应用是否有可更新的版本。如果存在可更新版本,您可以通过本服务为用户显示更新提醒。
3.png

4.png

应用市场推荐开发步骤

元服务卡片加桌

1.导入productViewManager模块及相关公共模块。
  1. import { productViewManager } from '@kit.StoreKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. import type { common, Want } from '@kit.AbilityKit';
  4. import { BusinessError } from '@kit.BasicServicesKit';
复制代码
2.构造元服务卡片参数。
  1. const uiContext = getContext(this) as common.UIAbilityContext
  2. const wantParam: Want = {
  3.   // 此处填入要加载的元服务的加桌链接
  4.   uri: 'xxx'
  5. }
  6. const callback: productViewManager.ServiceViewCallback = {
  7.   onReceive: (data: productViewManager.ServiceViewReceiveData) => {
  8.     hilog.info(0x0001, 'TAG', `loadService onReceive.result is ${data.result}, msg is ${data.msg}`);
  9.   },
  10.   onError: (error: BusinessError) => {
  11.     hilog.error(0x0001, 'TAG', `loadService onError.code is ${error.code}, message is ${error.message}`);
  12.   }
  13. }
复制代码
3.调用loadService方法,将步骤2中构造的参数依次传入接口中。
  1. // 调用接口,加载元服务加桌页面
  2. productViewManager.loadService(uiContext, wantParam, callback);
复制代码
应用详情页展示

方式一:loadProduct接口调用
1.导入productViewManager模块及相关公共模块。
  1. import { productViewManager } from '@kit.StoreKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. import type { common, Want } from '@kit.AbilityKit';
  4. import { BusinessError } from '@kit.BasicServicesKit';
复制代码
2.构造应用详情页参数。
  1. const uiContext = getContext(this) as common.UIAbilityContext
  2. const wantParam: Want = {
  3.   parameters: {
  4.      // 此处填入要加载的应用包名,例如: bundleName: 'com.huawei.hmsapp.books'
  5.     bundleName: 'com.xxx'
  6.   }
  7. }
  8. const callback: productViewManager.ProductViewCallback = {
  9.   onError: (error: BusinessError) => {
  10.     hilog.error(0x0001, 'TAG', `loadProduct onError.code is ${error.code}, message is ${error.message}`);
  11.   }
  12. }
复制代码
3.调用loadProduct方法,将步骤2中构造的参数依次传入接口中。
  1. // 调用接口,拉起应用详情页
  2. productViewManager.loadProduct(uiContext, wantParam, callback);
复制代码
方式二:DeepLink方式
构造拼接bundleName的DeepLink链接,其中bundleName为需要打开的应用包名,其格式为:
  1. store://appgallery.huawei.com/app/detail?id= + bundleName
复制代码
在应用中调用context.startAbility()方法,拉起应用市场应用详情页:
  1. import { BusinessError } from '@kit.BasicServicesKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. import type { common, Want } from '@kit.AbilityKit';
  4. // 拉起应用市场对应的应用详情页面
  5. function startAppGalleryDetailAbility(context: common.UIAbilityContext, bundleName: string): void {
  6.   let want: Want = {
  7.     action: 'ohos.want.action.appdetail', //隐式指定action为ohos.want.action.appdetail
  8.     uri: 'store://appgallery.huawei.com/app/detail?id=' + bundleName, //  bundleName为需要打开应用详情的应用包名
  9.   };
  10.   context.startAbility(want).then(() => {
  11.     hilog.info(0x0001, 'TAG', "Succeeded in starting Ability successfully.")
  12.   }).catch((error: BusinessError) => {
  13.     hilog.error(0x0001, 'TAG', `Failed to startAbility.Code: ${error.code}, message is ${error.message}`);
  14.   });
  15. }
  16. @Entry
  17. @Component
  18. struct StartAppGalleryDetailAbilityView {
  19.   @State message: string = '拉起应用市场详情页';
  20.   build() {
  21.     Row() {
  22.       Column() {
  23.         Button(this.message)
  24.           .fontSize(24)
  25.           .fontWeight(FontWeight.Bold)
  26.           .onClick(() => {
  27.             const context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
  28.             // 按实际需求获取应用的bundleName,例如bundleName: 'com.huawei.hmsapp.books'
  29.             const bundleName = 'xxxx';
  30.             startAppGalleryDetailAbility(context, bundleName);
  31.           })
  32.       }
  33.       .width('100%')
  34.     }
  35.     .height('100%')
  36.   }
  37. }
复制代码
在网页中打开DeepLink链接拉起应用市场应用详情页:
  1. <html lang="en">
  2.   <head>
  3.     <meta charset="UTF-8">
  4.   </head>
  5.   <body>
  6.    
  7.       <button type="button" onclick="openDeepLink()">拉起应用详情页</button>
  8.    
  9.   </body>
  10. </html>
复制代码
方式三:App Linking方式
构造拼接bundleName的App Linking链接,其中bundleName为需要打开的应用包名,其格式为:
  1. https://appgallery.huawei.com/app/detail?id= + bundleName
复制代码
在应用中调用openLink()接口拉起App Linking链接:
  1. import common from '@ohos.app.ability.common';
  2. import { BusinessError } from '@ohos.base';
  3. import { hilog } from '@kit.PerformanceAnalysisKit';
  4. @Entry
  5. @Component
  6. struct Index {
  7.   build() {
  8.     Button('start app linking', { type: ButtonType.Capsule, stateEffect: true })
  9.       .width('87%')
  10.       .height('5%')
  11.       .margin({ bottom: '12vp' })
  12.       .onClick(() => {
  13.         let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
  14.         // 需要拼接不同的应用包名,用以打开不同的应用详情页,例如:bundleName: 'com.huawei.hmsapp.books'
  15.         let bundleName: string = 'xxxx';
  16.         let link: string = 'https://appgallery.huawei.com/app/detail?id=' + bundleName;
  17.         // 以App Linking优先的方式在应用市场打开指定包名的应用详情页
  18.         context.openLink(link, { appLinkingOnly: false })
  19.           .then(() => {
  20.             hilog.info(0x0001, 'TAG', 'openlink success.');
  21.           })
  22.           .catch((error: BusinessError) => {
  23.             hilog.error(0x0001, 'TAG', `openlink failed. Code: ${error.code}, message is ${error.message}`);
  24.           });
  25.       })
  26.   }
  27. }
复制代码
在网页中打开App Linking链接:
  1. <html lang="en">
  2.   <head>
  3.     <meta charset="UTF-8">
  4.     <title>跳转示例</title>
  5.   </head>
  6.   <body>
  7.     AppLinking跳转示例
  8.   </body>
  9. </html>
复制代码
应用市场更新功能开发步骤

检测新版本

1.导入updateManager模块及相关公共模块。
  1. import { updateManager } from '@kit.StoreKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. import type { common } from '@kit.AbilityKit';
  4. import { BusinessError } from '@kit.BasicServicesKit';
复制代码
2.构造参数。
入参为common.UIAbilityContext类型的Context。
  1. let context: common.UIAbilityContext = getContext() as common.UIAbilityContext;
复制代码
3.调用checkAppUpdate方法。
  1. try {
  2.   updateManager.checkAppUpdate(context)
  3.     .then((checkResult: updateManager.CheckUpdateResult) => {
  4.       hilog.info(0, 'TAG', "Succeeded in checking Result updateAvailable:" + checkResult.updateAvailable);
  5.     }).catch((error: BusinessError) => {
  6.     hilog.error(0, 'TAG', `checkAppUpdate onError.code is ${error.code}, message is ${error.message}`);
  7.   });
  8. } catch (error) {
  9.   hilog.error(0, 'TAG', `checkAppUpdate onError.code is ${error.code}, message is ${error.message}`);
  10. }
复制代码
显示升级对话框

1.导入updateManager 模块及相关公共模块。
  1. import { updateManager } from '@kit.StoreKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. import type { common } from '@kit.AbilityKit';
  4. import { BusinessError } from '@kit.BasicServicesKit';
复制代码
2.构造参数。
入参为common.UIAbilityContext类型的Context。
  1. let context: common.UIAbilityContext = getContext() as common.UIAbilityContext;
复制代码
3.调用showUpdateDialog方法。
  1. try {
  2.   updateManager.showUpdateDialog(context)
  3.     .then((resultCode: updateManager.ShowUpdateResultCode) => {
  4.       hilog.info(0, 'TAG', "Succeeded in showing UpdateDialog resultCode:" + resultCode);
  5.     })
  6.     .catch((error: BusinessError) => {
  7.       hilog.error(0, 'TAG', `showUpdateDialog onError.code is ${error.code}, message is ${error.message}`);
  8.     });
  9. } catch (error) {
  10.   hilog.error(0, 'TAG', `showUpdateDialog onError.code is ${error.code}, message is ${error.message}`);
  11. }
复制代码
了解更多详情>>
访问应用市场服务联盟官网
获取应用市场推荐开发指导文档
获取应用市场更新功能开发指导文档

来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

相关推荐

您需要登录后才可以回帖 登录 | 立即注册