中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
如何获取推送服务push token
微信扫码分享
import { pushService } from '@kit.PushKit'; private getTokenSyn = async () => { try { const pushToken = await pushService.getToken(); hilog.info(0x0000, 'testTag', 'Get push token successfully!'); this.showFlag = 'Successfully got push token, please save it.'; } catch (err) { this.showFlag = 'Failed to get push token, please check the error log!'; let e: BusinessError = err as BusinessError; hilog.error(0x0000, 'testTag', 'Get push token catch error: %{public}d %{public}s', e.code, e.message); } }