【HarmonyOS NEXT】鸿蒙获取appIdentifier,Identifier 原创

George_wu_
发布于 2025-3-21 21:57
2313浏览
0收藏

一、前言

三方后台需要填写的所谓appIdentifier,Identifier信息,其实对应鸿蒙应用的appID。

二、解决方案:

注意,模拟器获取data.signatureInfo.appIndentifer为空。需要使用真机。

import { bundleManager} from '@kit.AbilityKit';


let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO
try {
  bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
  	// data.signatureInfo.appIndentifer
    hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
  }).catch((err: BusinessError) => {
    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
  });
} catch (err) {
  let message = (err as BusinessError).message;
  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.

注意:同一应用,指的是在agc portal创建的单个HarmonyOS应用/元服务;同一应用申请的debug profile或release profile中,appIdentifier一致; 因此,如果debug启用IDE自动签名,那么appIdentifier为随机分配(此appIdentifier不可作为应用正式的身份标识),不同于应用正式profile中的appIdentifier,appIdentifier会改变。

或者登陆使用华为开发者账号登录 ​​AppGallery Connect​

【HarmonyOS NEXT】鸿蒙获取appIdentifier,Identifier

一、前言

三方后台需要填写的所谓appIdentifier,Identifier信息,其实对应鸿蒙应用的appID。

二、解决方案:

注意,模拟器获取data.signatureInfo.appIndentifer为空。需要使用真机。

  import { bundleManager} from '@kit.AbilityKit';


let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO
try {
  bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
  	// data.signatureInfo.appIndentifer
    hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
  }).catch((err: BusinessError) => {
    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
  });
} catch (err) {
  let message = (err as BusinessError).message;
  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message);
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.

注意:同一应用,指的是在agc portal创建的单个HarmonyOS应用/元服务;同一应用申请的debug profile或release profile中,appIdentifier一致; 因此,如果debug启用IDE自动签名,那么appIdentifier为随机分配(此appIdentifier不可作为应用正式的身份标识),不同于应用正式profile中的appIdentifier,appIdentifier会改变。

或者登陆使用华为开发者账号登录 ​​AppGallery Connect​

【HarmonyOS NEXT】鸿蒙获取appIdentifier,Identifier-鸿蒙开发者社区

【HarmonyOS NEXT】鸿蒙获取appIdentifier,Identifier-鸿蒙开发者社区

©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
分类
收藏
回复
举报


回复
    相关推荐
    任职鸿蒙应用架构师。 HarmonyOS官方认证创作先锋
    觉得TA不错?点个关注精彩不错过
    31
    帖子
    0
    视频
    156
    声望
    7
    粉丝
    社区精华内容