【HarmonyOS】鸿蒙获取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.appIndentiferhilog.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);
}
或者登陆使用华为开发者账号登录 AppGallery Connect