中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
获取DeviceToken的方法
微信扫码分享
import { hilog } from '@kit.PerformanceAnalysisKit'; import { deviceCertificate } from '@kit.DeviceSecurityKit'; import { BusinessError} from '@kit.BasicServicesKit'; const TAG: string = '[DevCertManagerModel]'; // 请求deviceToken,并处理结果 try { deviceCertificate.getDeviceToken().then((token) => { hilog.debug(0x0000, TAG, 'Succeeded in executing getDeviceToken'); this.dispalyText = token; }).catch((err: BusinessError) => { hilog.error(0x0000, TAG, 'getDeviceToken failed! %{public}d %{public}s', err.code, err.message); }); } catch(err) { let error: BusinessError = err as BusinessError; hilog.error(0x0000, TAG, 'getDeviceToken failed! %{public}d %{public}s', err.code, err.message); }